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

Fix nested sessions' history saving #652

Merged
merged 1 commit into from
Aug 9, 2023
Merged

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Jul 20, 2023

Fix nested IRB sessions' history saving:

  1. Dynamically including HistorySavingAbility makes things unnecessarily complicated and should be avoided.
  2. Because both Reline and Readline use a single HISTORY constant to store history data. When nesting IRB sessions, only the first IRB session should handle history loading and saving so we can avoid duplicating history.
  3. History saving callback should NOT be stored in IRB.conf as it's recreated every time IRB.setup is called, which would happen when nesting IRB sessions.

Fixes #666 #659

@st0012 st0012 requested a review from a team July 20, 2023 20:29
@st0012 st0012 self-assigned this Jul 20, 2023
@@ -154,13 +151,6 @@ def initialize(irb, workspace = nil, input_method = nil)

def save_history=(val)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to have this save_history accessors on individual context objects, but it's better to keep them for compatibility.

lib/irb.rb Outdated Show resolved Hide resolved
@st0012 st0012 marked this pull request as draft July 31, 2023 12:53
@st0012 st0012 changed the title Simplify history saving activation Simplify and fix nested sessions' history saving Jul 31, 2023
@st0012 st0012 force-pushed the refactor-history-saving branch 2 times, most recently from 81b629a to a04b3c4 Compare August 4, 2023 16:55
@st0012 st0012 added the bug Something isn't working label Aug 4, 2023
@st0012 st0012 marked this pull request as ready for review August 4, 2023 17:16
@st0012 st0012 changed the title Simplify and fix nested sessions' history saving Fix nested sessions' history saving Aug 4, 2023
1. Dynamically including `HistorySavingAbility` makes things unnecessarily
   complicated and should be avoided.
2. Because both `Reline` and `Readline` use a single `HISTORY` constant
   to store history data. When nesting IRB sessions, only the first IRB
   session should handle history loading and saving so we can avoid
   duplicating history.
3. History saving callback should NOT be stored in `IRB.conf` as it's
   recreated every time `IRB.setup` is called, which would happen when
   nesting IRB sessions.
@st0012 st0012 linked an issue Aug 5, 2023 that may be closed by this pull request
@tompng tompng merged commit 0fef0ae into master Aug 9, 2023
47 checks passed
@tompng tompng deleted the refactor-history-saving branch August 9, 2023 14:57
matzbot pushed a commit to ruby/ruby that referenced this pull request Aug 9, 2023
(ruby/irb#652)

1. Dynamically including `HistorySavingAbility` makes things unnecessarily
   complicated and should be avoided.
2. Because both `Reline` and `Readline` use a single `HISTORY` constant
   to store history data. When nesting IRB sessions, only the first IRB
   session should handle history loading and saving so we can avoid
   duplicating history.
3. History saving callback should NOT be stored in `IRB.conf` as it's
   recreated every time `IRB.setup` is called, which would happen when
   nesting IRB sessions.

ruby/irb@0fef0ae160
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

Running irb on debugger on irb dose not save the irb history History is not saved with nested IRB sessions
2 participants