Skip to content

Commit

Permalink
Make sure history is saved after entering irb:rdbg sessions
Browse files Browse the repository at this point in the history
IRB saves history when exiting `Irb#run` with `IRB.conf[:AT_EXIT]`. But
because `irb:rdbg` doesn't run inside `Irb#run`, history is not saved
when exiting. Therefore, we need to register the history-saving callback
manually to `at_exit` when we start `irb:rdbg`.
  • Loading branch information
st0012 committed Jul 20, 2023
1 parent 26f86be commit 0b6e7c3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/irb/debug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def setup(irb)
irb.context.with_debugger = true
thread = Thread.current

at_exit do
irb.context.io.save_history
end if irb.context.io.support_history_saving?

DEBUGGER__.initialize_session{ IRB::Debug::UI.new(thread, irb) }
end

Expand All @@ -48,6 +52,10 @@ def setup(irb)
irb.context.with_debugger = true
thread = Thread.current

at_exit do
irb.context.io.save_history
end if irb.context.io.support_history_saving?

DEBUGGER__::SESSION.reset_ui(IRB::Debug::UI.new(thread, irb))
end

Expand Down

0 comments on commit 0b6e7c3

Please sign in to comment.