【问题标题】:copy-history is actually copying 'copy-history'复制历史实际上是复制“复制历史”
【发布时间】:2015-02-05 10:29:57
【问题描述】:

使用撬插件:撬剪贴板

当我输入“copy-history”来复制我的历史记录的最后一行时,它实际上是在复制“copy-history”并粘贴“copy-history”。

我在这里遗漏了什么吗?即使我给它一个范围选项,它也会复制我历史上没有的东西......

[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)>

【问题讨论】:

    标签: ruby pry


    【解决方案1】:

    我有同样的问题

    [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
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-01
    • 1970-01-01
    • 2012-03-12
    • 2013-08-09
    • 1970-01-01
    • 2015-06-04
    • 2020-11-20
    • 1970-01-01
    相关资源
    最近更新 更多