File tree Expand file tree Collapse file tree 4 files changed +61
-10
lines changed
Expand file tree Collapse file tree 4 files changed +61
-10
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,26 @@ def update conf
158158 SESSION . set_no_sigint_hook old , new
159159 end
160160 end
161+
162+ if_updated old_conf , conf , :irb_console do |old , new |
163+ if defined? ( SESSION ) && SESSION . active?
164+ # irb_console is switched from true to false
165+ if old
166+ Reline . completion_proc = nil
167+ Reline . output_modifier_proc = nil
168+ Reline . autocompletion = false
169+ Reline . dig_perfect_match_proc = nil
170+ SESSION . reset_ui UI_LocalConsole . new
171+ # irb_console is switched from false to true
172+ else
173+ if CONFIG [ :open ]
174+ SESSION . instance_variable_get ( :@ui ) . puts "\n IRB is not supported on the remote console."
175+ else
176+ SESSION . activate_irb_integration
177+ end
178+ end
179+ end
180+ end
161181 end
162182
163183 private def if_updated old_conf , new_conf , key
Original file line number Diff line number Diff line change @@ -202,18 +202,19 @@ def activate ui = nil, on_fork: false
202202 end
203203 @tp_thread_end . enable
204204
205- if CONFIG [ :irb_console ] && !CONFIG [ :open ]
206- require_relative "irb_integration"
207- thc . activate_irb_integration
208- end
209-
210205 # session start
211206 q << true
212207 session_server_main
213208 end
214209 first_q << :ok
215210
216211 q . pop
212+
213+ # For activating irb:rdbg with startup config like `RUBY_DEBUG_IRB_CONSOLE=1`
214+ # Because in that case the `Config#if_updated` callback would not be triggered
215+ if CONFIG [ :irb_console ] && !CONFIG [ :open ]
216+ activate_irb_integration
217+ end
217218 end
218219
219220 def deactivate
@@ -942,10 +943,11 @@ def register_default_command
942943 register_command 'irb' do |arg |
943944 if @ui . remote?
944945 @ui . puts "\n IRB is not supported on the remote console."
945- :retry
946946 else
947- request_eval :irb , nil
947+ config_set :irb_console , true
948948 end
949+
950+ :retry
949951 end
950952
951953 ### Trace
@@ -1876,6 +1878,12 @@ def check_unsafe
18761878 end
18771879 end
18781880
1881+ def activate_irb_integration
1882+ require_relative "irb_integration"
1883+ thc = get_thread_client ( @session_server )
1884+ thc . activate_irb_integration
1885+ end
1886+
18791887 def enter_postmortem_session exc
18801888 return unless exc . instance_variable_defined? :@__debugger_postmortem_frames
18811889
Original file line number Diff line number Diff line change @@ -1056,9 +1056,6 @@ def wait_next_action_
10561056 end
10571057 when :call
10581058 result = frame_eval ( eval_src )
1059- when :irb
1060- require_relative "irb_integration"
1061- activate_irb_integration
10621059 when :display , :try_display
10631060 failed_results = [ ]
10641061 eval_src . each_with_index { |src , i |
Original file line number Diff line number Diff line change @@ -35,6 +35,12 @@ def test_irb_command_is_disabled_in_remote_mode
3535 assert_line_text 'IRB is not supported on the remote console.'
3636 type 'q!'
3737 end
38+
39+ debug_code ( program , remote : :remote_only ) do
40+ type 'config set irb_console true'
41+ assert_line_text 'IRB is not supported on the remote console.'
42+ type 'q!'
43+ end
3844 end
3945
4046 def test_irb_command_switches_console_to_irb
@@ -47,6 +53,11 @@ def test_irb_command_switches_console_to_irb
4753 type 'next'
4854 type 'info'
4955 assert_line_text ( [ /a = 1/ , /b = nil/ ] )
56+
57+ # disable irb console
58+ type 'config set irb_console false'
59+ type '456'
60+ assert_raw_line_text '(rdbg) 456'
5061 type 'q!'
5162 end
5263 end
@@ -62,10 +73,25 @@ def test_irb_console_config_activates_irb
6273 type 'next'
6374 type 'info'
6475 assert_line_text ( [ /a = 1/ , /b = nil/ ] )
76+
77+ # disable irb console
78+ type 'config set irb_console false'
79+ type '456'
80+ assert_raw_line_text '(rdbg) 456'
6581 type 'q!'
6682 end
6783 ensure
6884 ENV [ "RUBY_DEBUG_IRB_CONSOLE" ] = nil
6985 end
86+
87+ private
88+
89+ # assert_line_text ignores the prompt line, so we can't use it to assert the prompt transition
90+ # assert_raw_line_text is a workaround for that
91+ def assert_raw_line_text ( expectation )
92+ @scenario . push ( Proc . new do |test_info |
93+ assert_include ( test_info . last_backlog . join , expectation )
94+ end )
95+ end
7096 end
7197end
You can’t perform that action at this time.
0 commit comments