diff options
author | Stan Lo <stan001212@gmail.com> | 2024-02-16 16:12:50 +0000 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2024-02-16 16:12:54 +0000 |
commit | b315826377bfa3fae6f513da12327c9133852486 (patch) | |
tree | 38a04918f59a448b2fdf4357f9e9a662474679cb /lib/irb.rb | |
parent | ff4f5c0cdd24234811094a07302765fabfe6dacf (diff) |
[ruby/irb] Support repeating debugger input by passing empty input
to it
(https://github.com/ruby/irb/pull/856)
* Test IRB's behaviour with empty input
* Handle empty input and pass it to debugger
Since `rdbg` accepts empty input to repeat the previous command, IRB
should take empty input in `irb:rdbg` sessions and pass them to the
debugger.
Currently, IRB simply ignores empty input and does nothing. This commit
creates `EmptyInput` to represent empty input so it can fit into the
current IRB's input processing flow in `Irb#eval_input`.
https://github.com/ruby/irb/commit/0e9db419be
Diffstat (limited to 'lib/irb.rb')
-rw-r--r-- | lib/irb.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/irb.rb b/lib/irb.rb index 67e03f8bc9..fd06626e9b 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -1082,16 +1082,17 @@ module IRB loop do code = readmultiline break unless code - - if code != "\n" - yield build_statement(code), @line_no - end + yield build_statement(code), @line_no @line_no += code.count("\n") rescue RubyLex::TerminateLineInput end end def build_statement(code) + if code.match?(/\A\n*\z/) + return Statement::EmptyInput.new + end + code.force_encoding(@context.io.encoding) command_or_alias, arg = code.split(/\s/, 2) # Transform a non-identifier alias (@, $) or keywords (next, break) |