diff --git a/README.md b/README.md index 23318977a..ddc085cd5 100644 --- a/README.md +++ b/README.md @@ -477,6 +477,7 @@ config set no_color true * `RUBY_DEBUG_NO_RELINE` (`no_reline`): Do not use Reline library (default: false) * `RUBY_DEBUG_NO_HINT` (`no_hint`): Do not show the hint on the REPL (default: false) * `RUBY_DEBUG_NO_LINENO` (`no_lineno`): Do not show line numbers (default: false) + * `RUBY_DEBUG_IRB_CONSOLE` (`irb_console`): Use IRB as the console (default: false) * CONTROL * `RUBY_DEBUG_SKIP_PATH` (`skip_path`): Skip showing/entering frames for given paths diff --git a/lib/debug/config.rb b/lib/debug/config.rb index e954b56bf..66383c88c 100644 --- a/lib/debug/config.rb +++ b/lib/debug/config.rb @@ -22,6 +22,7 @@ module DEBUGGER__ no_reline: ['RUBY_DEBUG_NO_RELINE', "UI: Do not use Reline library", :bool, "false"], no_hint: ['RUBY_DEBUG_NO_HINT', "UI: Do not show the hint on the REPL", :bool, "false"], no_lineno: ['RUBY_DEBUG_NO_LINENO', "UI: Do not show line numbers", :bool, "false"], + irb_console: ["RUBY_DEBUG_IRB_CONSOLE", "UI: Use IRB as the console", :bool, "false"], # control setting skip_path: ['RUBY_DEBUG_SKIP_PATH', "CONTROL: Skip showing/entering frames for given paths", :path], diff --git a/lib/debug/session.rb b/lib/debug/session.rb index 3db2f45da..86e8ea7e3 100644 --- a/lib/debug/session.rb +++ b/lib/debug/session.rb @@ -202,6 +202,11 @@ def activate ui = nil, on_fork: false end @tp_thread_end.enable + if CONFIG[:irb_console] && !CONFIG[:open] + require_relative "irb_integration" + thc.activate_irb_integration + end + # session start q << true session_server_main diff --git a/test/console/irb_test.rb b/test/console/irb_test.rb index 8cdf5801a..c4aaf3540 100644 --- a/test/console/irb_test.rb +++ b/test/console/irb_test.rb @@ -24,5 +24,22 @@ def test_irb_command_switches_console_to_irb type 'q!' end end + + def test_irb_console_config_activates_irb + ENV["RUBY_DEBUG_IRB_CONSOLE"] = "true" + + debug_code(program, remote: false) do + type '123' + assert_line_text 'irb:rdbg(main):002> 123' + type 'irb_info' + assert_line_text('IRB version:') + type 'next' + type 'info' + assert_line_text([/a = 1/, /b = nil/]) + type 'q!' + end + ensure + ENV["RUBY_DEBUG_IRB_CONSOLE"] = nil + end end end