summaryrefslogtreecommitdiff
path: root/lib/irb/ruby-lex.rb
diff options
context:
space:
mode:
authorStan Lo <stan001212@gmail.com>2023-08-13 19:30:30 +0100
committergit <svn-admin@ruby-lang.org>2023-08-13 18:30:34 +0000
commit7f8f62c93bf3d11a0321fa91823065a2ff36f6d0 (patch)
tree2dffe13305f50883f33644f9d701ebb832ec0ab4 /lib/irb/ruby-lex.rb
parent9099d62ac77cdca548bc4110e2cb03057ef0ac8f (diff)
[ruby/irb] Support seamless integration with ruby/debug
(https://github.com/ruby/irb/pull/575) * Support native integration with ruby/debug * Prevent using multi-irb and activating debugger at the same time Multi-irb makes a few assumptions: - IRB will manage all threads that host sub-irb sessions - All IRB sessions will be run on the threads created by IRB itself However, when using the debugger these assumptions are broken: - `debug` will freeze ALL threads when it suspends the session (e.g. when hitting a breakpoint, or performing step-debugging). - Since the irb-debug integration runs IRB as the debugger's interface, it will be run on the debugger's thread, which is not managed by IRB. So we should prevent the 2 features from being used at the same time. To do that, we check if the other feature is already activated when executing the commands that would activate the other feature. https://github.com/ruby/irb/commit/d8fb3246be
Diffstat (limited to 'lib/irb/ruby-lex.rb')
-rw-r--r--lib/irb/ruby-lex.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 7d4f8a514c..282e6ef05f 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -183,6 +183,10 @@ class RubyLex
prompt(opens, continue, line_num_offset)
end
+ def increase_line_no(addition)
+ @line_no += addition
+ end
+
def readmultiline
save_prompt_to_context_io([], false, 0)
@@ -220,7 +224,7 @@ class RubyLex
code.force_encoding(@context.io.encoding)
yield code, @line_no, assignment_expression?(code)
end
- @line_no += code.count("\n")
+ increase_line_no(code.count("\n"))
rescue TerminateLineInput
end
end