Repository navigation
Stop irb:rdbg from saving duplicated history when there's no prior history file - #853
Merged
Merged
Conversation
irb:rdbg from saving duplicated history when there's no prior history file
st0012
commented
Jan 31, 2024
| step | ||
| irb_info | ||
| puts Reline::HISTORY.to_a.to_s | ||
| q! |
Member
Author
There was a problem hiding this comment.
Without the fix, the history would be:
+ 'irb session'
+ next
+ 'irb session'
+ next
+ 'irb:debug session'
+ 'irb session'
+ next
+ 'irb:debug session'
+ step
+ 'irb session'
+ next
+ 'irb:debug session'
+ step
+ irb_info
+ puts Reline::HISTORY.to_a.to_s
'irb session'
next
'irb:debug session'
step
irb_info
puts Reline::HISTORY.to_a.to_s
q!
st0012
force-pushed
the
fix-debug-#1064
branch
from
January 31, 2024 23:44
145606d to
7850ad0
Compare
The issue (https://github.com/ruby/debug/issues/1064) is caused by a combination of factors: 1. When user starts an IRB session without a history file, the `@loaded_history_lines` ivar is not defined. 2. If the user then starts the `irb:rdbg` session, the history counter is not set, because the `@loaded_history_lines` is not defined. 3. Because `irb:rdbg` saves the history before passing Ruby expression to the debugger, it saves the history with duplicated lines. The number grows in exponential order. 4. When the user exits the `irb:rdbg` session, the history file could be bloated with duplicated lines. This commit fixes the issue by resetting the history counter even when `@loaded_history_lines` is not defined.
st0012
force-pushed
the
fix-debug-#1064
branch
from
February 1, 2024 00:29
7850ad0 to
763c0b7
Compare
tompng
approved these changes
Feb 1, 2024
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
Feb 1, 2024
not defined (ruby/irb#853) The issue (https://github.com/ruby/debug/issues/1064) is caused by a combination of factors: 1. When user starts an IRB session without a history file, the `@loaded_history_lines` ivar is not defined. 2. If the user then starts the `irb:rdbg` session, the history counter is not set, because the `@loaded_history_lines` is not defined. 3. Because `irb:rdbg` saves the history before passing Ruby expression to the debugger, it saves the history with duplicated lines. The number grows in exponential order. 4. When the user exits the `irb:rdbg` session, the history file could be bloated with duplicated lines. This commit fixes the issue by resetting the history counter even when `@loaded_history_lines` is not defined. ruby/irb@4afc98c258
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The issue (#855) is caused by a combination of factors:
@loaded_history_linesivar is not defined.irb:rdbgsession, the history counter is not set, because the@loaded_history_linesis not defined.irb:rdbgsaves the history before passing Ruby expression to the debugger, it saves the history with duplicated lines. The number grows in exponential order.irb:rdbgsession, the history file could be bloated with duplicated lines.This commit fixes the issue by resetting the history counter even when
@loaded_history_linesis not defined.Closes #855