diff options
author | Stan Lo <stan.lo@shopify.com> | 2022-12-09 23:39:12 +0000 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-12-09 23:39:17 +0000 |
commit | 381e128c135e491689714cb69353d11e782f5994 (patch) | |
tree | bdb129826f9b1bf8f1f2ebf013883664f2006861 /lib/irb/cmd | |
parent | daa893db412c6ae814d0291b4ac6fc62a466d394 (diff) |
[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.
Diffstat (limited to 'lib/irb/cmd')
-rw-r--r-- | lib/irb/cmd/debug.rb | 9 | ||||
-rw-r--r-- | lib/irb/cmd/step.rb | 3 |
2 files changed, 10 insertions, 2 deletions
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?('<internal:prelude>') + 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 |