You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Handling Interrupt exception and calling .readline again seems to break Interrupt handling in LineEditor.reset #351
Instead, it works the first time, but the second time, I receive the following trace:
/Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.7/lib/reline/ansi.rb:282:in `scroll_down': stack level too deep (SystemStackError)
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.7/lib/reline/line_editor.rb:313:in `scroll_down'
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.7/lib/reline/line_editor.rb:160:in `block in reset'
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.7/lib/reline/line_editor.rb:169:in `block in reset'
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.7/lib/reline/line_editor.rb:169:in `block in reset'
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.7/lib/reline/line_editor.rb:169:in `block in reset'
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.7/lib/reline/line_editor.rb:169:in `block in reset'
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.7/lib/reline/line_editor.rb:169:in `block in reset'
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.7/lib/reline/line_editor.rb:169:in `block in reset'
... 13088 levels...
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.7/lib/reline.rb:244:in `inner_readline'
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.7/lib/reline.rb:191:in `readline'
from /usr/local/Cellar/ruby/3.0.2/lib/ruby/3.0.0/forwardable.rb:238:in `readline'
from exe/reline-test.rb:8:in `<main>'
I have gem 'reline', '~> 0.2.7' in my Gemfile, and you can see from the trace that 0.2.7 is the version of reline I am using.
The stdlib docs mention ways to handle ^C. I tried trap("INT", "SIG_IGN"), which doesn't seem to be what I want. This seems to temporarily hide the prompt, and doesn't clear the inputted line. (Type 'hello' then ^C, then ' world'. You will see '> hello world')
I also tried adding trap("INT", "DEFAULT") right before retry, and this fixes the issue but feels like I am working around an issue in reline. If I am approaching this the wrong way, let me know. Thanks for your time.
I get the same behavior with 0.2.8.pre9 as well. The stack trace is slightly different:
/Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.8.pre.9/lib/reline/line_editor.rb:839:in `block in clear_dialog': stack level too deep (SystemStackError)
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.8.pre.9/lib/reline/line_editor.rb:838:in `each'
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.8.pre.9/lib/reline/line_editor.rb:838:in `clear_dialog'
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.8.pre.9/lib/reline/line_editor.rb:154:in `block in reset'
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.8.pre.9/lib/reline/line_editor.rb:170:in `block in reset'
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.8.pre.9/lib/reline/line_editor.rb:170:in `block in reset'
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.8.pre.9/lib/reline/line_editor.rb:170:in `block in reset'
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.8.pre.9/lib/reline/line_editor.rb:170:in `block in reset'
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.8.pre.9/lib/reline/line_editor.rb:170:in `block in reset'
... 13088 levels...
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.8.pre.9/lib/reline.rb:322:in `inner_readline'
from /Users/alexg/.gem/ruby/3.0.0/gems/reline-0.2.8.pre.9/lib/reline.rb:265:in `readline'
from /usr/local/Cellar/ruby/3.0.2/lib/ruby/3.0.0/forwardable.rb:238:in `readline'
from exe/reline-test.rb:8:in `<main>'
Activity
win93 commentedon Sep 19, 2021
I get the same behavior with 0.2.8.pre9 as well. The stack trace is slightly different:
win93 commentedon Sep 19, 2021
I am not very familiar with how signals are managed in this library, but the fix for this may be as simple as:
This has the effect of installing the old_trap back in place after the installed trap fires. In other words, the handling would be a one-time event.