Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correct binding in debug mode #1007

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/irb/debug/ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def puts str = nil
def readline _
setup_interrupt do
tc = DEBUGGER__::SESSION.instance_variable_get(:@tc)
cmd = @irb.debug_readline(tc.current_frame.binding || TOPLEVEL_BINDING)
cmd = @irb.debug_readline(tc.current_frame.eval_binding || TOPLEVEL_BINDING)

case cmd
when nil # when user types C-d
Expand Down
17 changes: 17 additions & 0 deletions test/irb/test_debugger_integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,23 @@ def bar
assert_include(output, "InputMethod: RelineInputMethod")
end

def test_irb_command_can_check_local_variables
write_ruby <<~'ruby'
binding.irb
ruby

output = run_ruby_file do
type "debug"
type 'foobar = IRB'
type "show_source foobar.start"
type "show_source = 'Foo'"
type "show_source + 'Bar'"
type "continue"
end
assert_include(output, "def start(ap_path = nil)")
assert_include(output, '"FooBar"')
end

def test_help_command_is_delegated_to_the_debugger
write_ruby <<~'ruby'
binding.irb
Expand Down
Loading