Repository navigation
Refactor history move and history search - #651
Merged
Merged
Conversation
tompng
force-pushed
the
history_move_search_refactor
branch
from
March 20, 2024 05:23
133dd11 to
139be1f
Compare
tompng
force-pushed
the
history_move_search_refactor
branch
from
March 26, 2024 02:29
139be1f to
498007a
Compare
ima1zumi
approved these changes
Apr 16, 2024
Comment on lines
+1701
to
+1709
| private def ed_search_prev_history(key, arg: 1) | ||
| substr = current_line.byteslice(0, @byte_pointer) | ||
| return if @history_pointer == 0 | ||
| return if @history_pointer.nil? && substr.empty? && !current_line.empty? | ||
|
|
||
| history_range = 0...(@history_pointer || Reline::HISTORY.size) | ||
| h_pointer, line_index = search_history(substr, history_range.reverse_each) | ||
| return unless h_pointer | ||
| move_history(h_pointer, line: line_index || :start, cursor: @byte_pointer) |
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.
Fixes #596
Add method
move_historyUsing this will prevent inconsistency of
@history_pointerand@line_backup_in_historythat caused #596. It also reduce duplicated code.Refactored
generate_searcherused for incremental search.generate_searcheris used inincremental_search_historyBoth searcher and incremental_search_history was modifying LineEditor's state, making hard to understand the behavior.
Now searcher only searches, does not mutate LineEditor's state.
(Also changed the implementation from Fiber to lambda. )