复制历史实际上是复制'复制历史'

时间:2015-02-05 10:29:58

标签: ruby pry

使用pry插件:pry-clipboard

当我输入'复制历史'来复制我的历史记录的最后一行时,它实际上是复制'复制历史'并粘贴'复制历史'。

我在这里遗漏了什么吗?即使我给它提供了一个范围选项,它也会复制甚至不在我历史中的东西......

[19] pry(RSpec::ExampleGroups::MyHelperModuleWorks)> copy-history
-*-*- Copy history to clipboard -*-*-
copy-history
[20] pry(RSpec::ExampleGroups::MyHelperModuleWorks)>

~~~~

[5] pry(RSpec::ExampleGroups::MyHelperModuleWorks)> history
1: puts "this is what I want to copy"
2: puts "this also should get copied"
3: puts "and this..."
4: puts "but we don't want this"
[6] pry(RSpec::ExampleGroups::MyHelperModuleWorks)> copy-history --range 1..3
NoMethodError: undefined method `<' for true:TrueClass
from /Users/MY_USR_NAME/.rvm/rubies/ruby-2.1.3/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/code/code_range.rb:50:in `find_start_index'
[6] pry(RSpec::ExampleGroups::MyHelperModuleWorks)>

1 个答案:

答案 0 :(得分:0)

我有同样的问题

[19] pry(RSpec::ExampleGroups::MyHelperModuleWorks)> copy-history
-*-*- Copy history to clipboard -*-*-
copy-history
[20] pry(RSpec::ExampleGroups::MyHelperModuleWorks)>
改变一条线为我工作。

diff --git a/lib/pry-clipboard.rb b/lib/pry-clipboard.rb
index 146a003..2c643be 100644
--- a/lib/pry-clipboard.rb
+++ b/lib/pry-clipboard.rb
@@ -50,6 +50,7 @@ module PryClipboard
       end

       def process
+        #binding.pry
         history = Pry::Code(Pry.history.to_a)

         history = if num_arg
@@ -66,7 +67,7 @@ module PryClipboard
             n = history.lines.count if n > history.lines.count
             history.take_lines(-n, n)
           else
-            history.take_lines(-1, 1)
+            history.take_lines(-2, 1)
           end
         end