diff options
author | Stan Lo <stan001212@gmail.com> | 2023-08-29 19:08:15 +0100 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-08-29 18:36:16 +0000 |
commit | f37f357e808a7435f56946cd603a333feba7691b (patch) | |
tree | 19b6c5c33b5883898e28df0f5df0cd155c0ae658 /lib | |
parent | c58561b5e3f597867a6e62f451a77ea27a6b9150 (diff) |
[ruby/irb] Improve help/show_cmds message during debugger
integration
(https://github.com/ruby/irb/pull/693)
* `help` should display debugger's help during irb:rdbg session
* Update `show_cmds`'s output when in irb:rdbg session
https://github.com/ruby/irb/commit/4029c2e564
Diffstat (limited to 'lib')
-rw-r--r-- | lib/irb/cmd/show_cmds.rb | 15 | ||||
-rw-r--r-- | lib/irb/statement.rb | 4 |
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/irb/cmd/show_cmds.rb b/lib/irb/cmd/show_cmds.rb index cef6254ca0..7d6b3ec266 100644 --- a/lib/irb/cmd/show_cmds.rb +++ b/lib/irb/cmd/show_cmds.rb @@ -15,6 +15,16 @@ module IRB def execute(*args) commands_info = IRB::ExtendCommandBundle.all_commands_info commands_grouped_by_categories = commands_info.group_by { |cmd| cmd[:category] } + + if irb_context.with_debugger + # Remove the original "Debugging" category + commands_grouped_by_categories.delete("Debugging") + # Remove the `help` command as it's delegated to the debugger + commands_grouped_by_categories["Context"].delete_if { |cmd| cmd[:display_name] == :help } + # Add an empty "Debugging (from debug.gem)" category at the end + commands_grouped_by_categories["Debugging (from debug.gem)"] = [] + end + longest_cmd_name_length = commands_info.map { |c| c[:display_name].length }.max output = StringIO.new @@ -29,6 +39,11 @@ module IRB output.puts end + # Append the debugger help at the end + if irb_context.with_debugger + output.puts DEBUGGER__.help + end + Pager.page_content(output.string) end end diff --git a/lib/irb/statement.rb b/lib/irb/statement.rb index 9493c3ffb1..b12110600c 100644 --- a/lib/irb/statement.rb +++ b/lib/irb/statement.rb @@ -60,7 +60,9 @@ module IRB end def should_be_handled_by_debugger? - IRB::ExtendCommand::DebugCommand > @command_class + require_relative 'cmd/help' + require_relative 'cmd/debug' + IRB::ExtendCommand::DebugCommand > @command_class || IRB::ExtendCommand::Help == @command_class end def evaluable_code |