Skip to content
New issue

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

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

Already on GitHub? # to your account

Load history when starting a direct debug session #1046

Merged
merged 3 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions lib/irb/debug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def configure_irb_for_debugger(irb)
IRB.instance_variable_set(:@debugger_irb, irb)
irb.context.with_debugger = true
irb.context.irb_name += ":rdbg"
irb.context.io.load_history
st0012 marked this conversation as resolved.
Show resolved Hide resolved
end

module SkipPathHelperForIRB
Expand Down
22 changes: 22 additions & 0 deletions test/irb/test_history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,28 @@ def foo
HISTORY
end

def test_direct_debug_session_loads_history
@envs['RUBY_DEBUG_IRB_CONSOLE'] = "1"
write_history <<~HISTORY
old_history_1
old_history_2
old_history_3
HISTORY

write_ruby <<~'RUBY'
require 'debug'
debugger
binding.irb # needed to satisfy run_ruby_file
RUBY

output = run_ruby_file do
type "history"
type "exit!"
end

assert_include(output, "old_history_3")
st0012 marked this conversation as resolved.
Show resolved Hide resolved
end

private

def write_history(history)
Expand Down
Loading