gpt4 book ai didi

ruby - copy-history 实际上是复制 'copy-history'

转载 作者:行者123 更新时间:2023-12-04 16:49:15 35 4
gpt4 key购买 nike

使用 pry 插件:pry-clipboard

当我输入“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)>

最佳答案

我遇到了同样的问题

[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

关于ruby - copy-history 实际上是复制 'copy-history',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28341575/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com