mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-01 21:21:15 -03:00
Add automatic history search page change when deleting last element on last page
This commit is contained in:
committed by
Johannes Altmanninger
parent
4e965cba47
commit
3436836b94
@@ -5082,6 +5082,7 @@ struct HistoryPagerResult {
|
|||||||
matched_commands: Vec<Completion>,
|
matched_commands: Vec<Completion>,
|
||||||
range: Range<usize>,
|
range: Range<usize>,
|
||||||
first_shown: usize,
|
first_shown: usize,
|
||||||
|
motion: Option<SelectionMotion>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq)]
|
#[derive(Eq, PartialEq)]
|
||||||
@@ -5094,6 +5095,7 @@ enum HistoryPagerInvocation {
|
|||||||
fn history_pager_search(
|
fn history_pager_search(
|
||||||
history: &Arc<History>,
|
history: &Arc<History>,
|
||||||
direction: SearchDirection,
|
direction: SearchDirection,
|
||||||
|
motion: Option<SelectionMotion>,
|
||||||
history_index: usize,
|
history_index: usize,
|
||||||
search_string: &wstr,
|
search_string: &wstr,
|
||||||
) -> HistoryPagerResult {
|
) -> HistoryPagerResult {
|
||||||
@@ -5143,10 +5145,22 @@ fn history_pager_search(
|
|||||||
next_match_found = search.go_to_next_match(SearchDirection::Backward);
|
next_match_found = search.go_to_next_match(SearchDirection::Backward);
|
||||||
}
|
}
|
||||||
let last_index = search.current_index();
|
let last_index = search.current_index();
|
||||||
HistoryPagerResult {
|
let range = first_index..last_index;
|
||||||
matched_commands: completions,
|
if completions.is_empty() && range != (0..history.size() + 1) {
|
||||||
range: first_index..last_index,
|
history_pager_search(
|
||||||
first_shown,
|
history,
|
||||||
|
SearchDirection::Forward,
|
||||||
|
Some(SelectionMotion::Prev),
|
||||||
|
history.size() + 1,
|
||||||
|
search_string,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
HistoryPagerResult {
|
||||||
|
matched_commands: completions,
|
||||||
|
range,
|
||||||
|
first_shown,
|
||||||
|
motion,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5183,7 +5197,7 @@ fn fill_history_pager(
|
|||||||
let performer = {
|
let performer = {
|
||||||
let history = self.history.clone();
|
let history = self.history.clone();
|
||||||
let search_term = search_term.clone();
|
let search_term = search_term.clone();
|
||||||
move || history_pager_search(&history, direction, index, &search_term)
|
move || history_pager_search(&history, direction, motion, index, &search_term)
|
||||||
};
|
};
|
||||||
let canary = Rc::downgrade(&self.canary);
|
let canary = Rc::downgrade(&self.canary);
|
||||||
let completion = move |zelf: &mut Reader, result: HistoryPagerResult| {
|
let completion = move |zelf: &mut Reader, result: HistoryPagerResult| {
|
||||||
@@ -5216,7 +5230,7 @@ fn fill_history_pager(
|
|||||||
zelf.pager.set_selected_completion_index(old_pager_index);
|
zelf.pager.set_selected_completion_index(old_pager_index);
|
||||||
zelf.pager_selection_changed();
|
zelf.pager_selection_changed();
|
||||||
}
|
}
|
||||||
if let Some(motion) = motion {
|
if let Some(motion) = result.motion {
|
||||||
zelf.select_completion_in_direction(motion, true);
|
zelf.select_completion_in_direction(motion, true);
|
||||||
}
|
}
|
||||||
zelf.super_highlight_me_plenty();
|
zelf.super_highlight_me_plenty();
|
||||||
|
|||||||
Reference in New Issue
Block a user