Don't restart search if we maintain search mode

Currently, the search always restarts when moving from the present.
For example:
1. Do a few backward searches.
2. Use PageDown to return to the present.
3. Do another backward search.
4. Now, PageUp does nothing because the search was restarted, even if we maintained search mode.
This commit is contained in:
kerty
2025-02-02 23:40:38 +03:00
committed by Johannes Altmanninger
parent 8a86b4e4fc
commit c1c23269d2
2 changed files with 6 additions and 5 deletions

View File

@@ -2982,7 +2982,7 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) {
let was_active_before = self.history_search.active();
if self.history_search.is_at_present() {
if self.history_search.is_at_present() && mode != self.history_search.mode() {
let el = &self.data.command_line;
if mode == SearchMode::Token {
// Searching by token.
@@ -3331,15 +3331,13 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) {
},
false,
);
} else {
} else if self.history_search.active() {
if up {
self.history_search.go_to_oldest();
} else {
self.history_search.go_to_present();
}
if self.history_search.active() {
self.update_command_line_from_history_search();
}
self.update_command_line_from_history_search();
}
}
rl::UpLine | rl::DownLine => {

View File

@@ -79,6 +79,9 @@ pub fn by_line(&self) -> bool {
pub fn by_prefix(&self) -> bool {
self.mode == SearchMode::Prefix
}
pub fn mode(&self) -> SearchMode {
self.mode
}
/// Move the history search in the given direction `dir`.
pub fn move_in_direction(&mut self, dir: SearchDirection) -> bool {