-
Notifications
You must be signed in to change notification settings - Fork 118
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 history-saving feature #642
Merged
Conversation
This file contains 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
The HistorySavingAbility module doesn't do anything if the input method class doesn't define HISTORY. - https://github.com/ruby/irb/blob/3ac96be660bf052902fb4e532c7a46cf294b71eb/lib/irb/history.rb#L10 - https://github.com/ruby/irb/blob/3ac96be660bf052902fb4e532c7a46cf294b71eb/lib/irb/history.rb#L34 This patch defines RelineInputMethod::HISTORY to avoid this.
Instead of checking the existence of `input_method_class::HISTORY`, we should make every input method class declare if it supports history saving or not. Since the default value is `false`, it shouldn't break any custom input method that inherits from `IRB::InputMethod`.
st0012
commented
Jul 14, 2023
(IRB.conf[:MAIN_CONTEXT] || self).init_save_history | ||
context = (IRB.conf[:MAIN_CONTEXT] || self) | ||
if context.io.support_history_saving? && !context.io.singleton_class.include?(HistorySavingAbility) | ||
context.io.extend(HistorySavingAbility) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to put these in the same place to make future refactor easier.
tompng
approved these changes
Jul 14, 2023
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
Jul 14, 2023
(ruby/irb#642) * Define RelineInputMethod::HISTORY The HistorySavingAbility module doesn't do anything if the input method class doesn't define HISTORY. - https://github.com/ruby/irb/blob/3ac96be660bf052902fb4e532c7a46cf294b71eb/lib/irb/history.rb#L10 - https://github.com/ruby/irb/blob/3ac96be660bf052902fb4e532c7a46cf294b71eb/lib/irb/history.rb#L34 This patch defines RelineInputMethod::HISTORY to avoid this. * Improve history-saving's ability check Instead of checking the existence of `input_method_class::HISTORY`, we should make every input method class declare if it supports history saving or not. Since the default value is `false`, it shouldn't break any custom input method that inherits from `IRB::InputMethod`. ruby/irb@aec7a5b3f5
thanks for the quick fix - is this going to get a release today? |
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
HistorySavingAbility
module doesn't do anything if the input method class doesn't defineHISTORY
.irb/lib/irb/history.rb
Line 10 in 3ac96be
irb/lib/irb/history.rb
Line 34 in 3ac96be
That's why when #633 breaks history-saving, it went unnoticed.
This patch defines
RelineInputMethod::HISTORY
to avoid this.Also, instead of checking the existence of
input_method_class::HISTORY
, we should make every input method class declare if it supports history saving or not. With this approach, similar issues would be caught by tests in the future.Since the default value is
false
, it shouldn't break any custom input method that inherits fromIRB::InputMethod
.Closes #641