mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-04 07:21:14 -03:00
Separate SelectionMotion from HistoryPagerInvocation
This commit is contained in:
committed by
Johannes Altmanninger
parent
9b14408b1b
commit
4e965cba47
@@ -1271,6 +1271,7 @@ fn command_line_changed(
|
||||
if self.history_pager.is_some() {
|
||||
self.fill_history_pager(
|
||||
HistoryPagerInvocation::Anew,
|
||||
Some(SelectionMotion::Next),
|
||||
SearchDirection::Backward,
|
||||
);
|
||||
return;
|
||||
@@ -2723,6 +2724,7 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) {
|
||||
}
|
||||
self.fill_history_pager(
|
||||
HistoryPagerInvocation::Advance,
|
||||
Some(SelectionMotion::Next),
|
||||
SearchDirection::Forward,
|
||||
);
|
||||
return;
|
||||
@@ -2992,6 +2994,7 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) {
|
||||
}
|
||||
self.fill_history_pager(
|
||||
HistoryPagerInvocation::Advance,
|
||||
Some(SelectionMotion::Next),
|
||||
SearchDirection::Backward,
|
||||
);
|
||||
return;
|
||||
@@ -3071,6 +3074,7 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) {
|
||||
self.history.save();
|
||||
self.fill_history_pager(
|
||||
HistoryPagerInvocation::Refresh,
|
||||
None,
|
||||
SearchDirection::Backward,
|
||||
);
|
||||
}
|
||||
@@ -5150,6 +5154,7 @@ impl ReaderData {
|
||||
fn fill_history_pager(
|
||||
&mut self,
|
||||
why: HistoryPagerInvocation,
|
||||
motion: Option<SelectionMotion>,
|
||||
mut direction: SearchDirection, /* = Backward */
|
||||
) {
|
||||
let index;
|
||||
@@ -5171,7 +5176,7 @@ fn fill_history_pager(
|
||||
let history_pager = self.history_pager.as_ref().unwrap();
|
||||
direction = SearchDirection::Backward;
|
||||
index = history_pager.start;
|
||||
old_pager_index = Some(self.pager.selected_completion_index());
|
||||
old_pager_index = self.pager.selected_completion_index();
|
||||
}
|
||||
}
|
||||
let search_term = self.pager.search_field_line.text().to_owned();
|
||||
@@ -5208,11 +5213,11 @@ fn fill_history_pager(
|
||||
};
|
||||
zelf.pager.set_completions(&result.matched_commands, false);
|
||||
if why == HistoryPagerInvocation::Refresh {
|
||||
zelf.pager
|
||||
.set_selected_completion_index(old_pager_index.unwrap());
|
||||
zelf.pager.set_selected_completion_index(old_pager_index);
|
||||
zelf.pager_selection_changed();
|
||||
} else {
|
||||
zelf.select_completion_in_direction(SelectionMotion::Next, true);
|
||||
}
|
||||
if let Some(motion) = motion {
|
||||
zelf.select_completion_in_direction(motion, true);
|
||||
}
|
||||
zelf.super_highlight_me_plenty();
|
||||
zelf.layout_and_repaint(L!("history-pager"));
|
||||
|
||||
@@ -81,10 +81,9 @@ pub fn by_prefix(&self) -> bool {
|
||||
|
||||
/// Move the history search in the given direction `dir`.
|
||||
pub fn move_in_direction(&mut self, dir: SearchDirection) -> bool {
|
||||
if dir == SearchDirection::Forward {
|
||||
self.move_forwards()
|
||||
} else {
|
||||
self.move_backwards()
|
||||
match dir {
|
||||
SearchDirection::Forward => self.move_forwards(),
|
||||
SearchDirection::Backward => self.move_backwards(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user