From 381e128c135e491689714cb69353d11e782f5994 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Fri, 9 Dec 2022 23:39:12 +0000 Subject: [ruby/irb] Fix step command (https://github.com/ruby/irb/pull/477) The current `next` pre-command workaround on IRB source stepping moves the location by 1 extra line. A better way is to make `debug` skip IRB frames completely, which is what this commit does. It also fixes the step command's test. The `|` in regexp was not escaped so it was always incorrectly matched. --- lib/irb/cmd/debug.rb | 9 +++++++++ lib/irb/cmd/step.rb | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/irb') diff --git a/lib/irb/cmd/debug.rb b/lib/irb/cmd/debug.rb index 76f17e3c2f..e6e812e075 100644 --- a/lib/irb/cmd/debug.rb +++ b/lib/irb/cmd/debug.rb @@ -55,6 +55,13 @@ module IRB end end + module SkipPathHelperForIRB + def skip_internal_path?(path) + # The latter can be removed once https://github.com/ruby/debug/issues/866 is resolved + super || path.match?(IRB_DIR) || path.match?('') + end + end + def setup_debugger unless defined?(DEBUGGER__::SESSION) begin @@ -75,6 +82,8 @@ module IRB end frames end + + DEBUGGER__::ThreadClient.prepend(SkipPathHelperForIRB) end true diff --git a/lib/irb/cmd/step.rb b/lib/irb/cmd/step.rb index d3d0f16291..2bc74a9d79 100644 --- a/lib/irb/cmd/step.rb +++ b/lib/irb/cmd/step.rb @@ -8,8 +8,7 @@ module IRB module ExtendCommand class Step < DebugCommand def execute(*args) - # Run `next` first to move out of binding.irb - super(pre_cmds: "next", do_cmds: ["step", *args].join(" ")) + super(do_cmds: ["step", *args].join(" ")) end end end -- cgit v1.2.1