Disable redundant filtering in history pager

Part of #10143
This commit is contained in:
Shou Ya 2023-12-09 01:10:47 +09:00 committed by Johannes Altmanninger
parent 2358d4dec8
commit 31d157f117
3 changed files with 15 additions and 11 deletions

View file

@ -582,7 +582,7 @@ impl Pager {
}
// Sets the set of completions.
pub fn set_completions(&mut self, raw_completions: &[Completion]) {
pub fn set_completions(&mut self, raw_completions: &[Completion], enable_refilter: bool) {
self.selected_completion_idx = None;
// Get completion infos out of it.
self.unfiltered_completion_infos = process_completions_into_infos(raw_completions);
@ -596,7 +596,11 @@ impl Pager {
self.measure_completion_infos();
// Refilter them.
self.refilter_completions();
if enable_refilter {
self.refilter_completions();
} else {
self.completion_infos = self.unfiltered_completion_infos.clone();
}
self.have_unrendered_completions = true;
}
@ -1254,7 +1258,7 @@ mod pager_ffi {
fn rendering_needs_update(&self, rendering: &PageRendering) -> bool;
fn search_field_line(&mut self) -> *mut EditableLine;
#[cxx_name = "set_completions"]
fn set_completions_ffi(&mut self, completions: &CompletionListFfi);
fn set_completions_ffi(&mut self, completions: &CompletionListFfi, enable_refilter: bool);
fn set_fully_disclosed(&mut self);
#[cxx_name = "set_prefix"]
fn set_prefix_ffi(&mut self, prefix: &CxxWString, highlight: bool);
@ -1317,8 +1321,8 @@ impl Pager {
fn set_extra_progress_text(&mut self, text: &CxxWString) {
self.extra_progress_text = text.from_ffi();
}
fn set_completions_ffi(&mut self, completions: &CompletionListFfi) {
self.set_completions(&completions.0)
fn set_completions_ffi(&mut self, completions: &CompletionListFfi, enable_refilter: bool) {
self.set_completions(&completions.0, enable_refilter)
}
fn selected_completion_index_ffi(&self) -> usize {
self.selected_completion_idx.unwrap_or(PAGER_SELECTION_NONE)

View file

@ -24,7 +24,7 @@ add_test!("test_pager_navigation", || {
}
let mut pager = Pager::default();
pager.set_completions(&completions);
pager.set_completions(&completions, true);
pager.set_term_size(&Termsize::defaults());
let mut render = pager.render();
@ -136,7 +136,7 @@ add_test!("test_pager_layout", || {
StringFuzzyMatch::exact_match(),
CompleteFlags::default(),
)];
pager.set_completions(&c1s);
pager.set_completions(&c1s, true);
validate!(&mut pager, 26, L!("abcdefghij (1234567890)"));
validate!(&mut pager, 25, L!("abcdefghij (1234567890)"));
@ -157,7 +157,7 @@ add_test!("test_pager_layout", || {
StringFuzzyMatch::exact_match(),
CompleteFlags::default(),
)];
pager.set_completions(&c2s);
pager.set_completions(&c2s, true);
validate!(&mut pager, 26, L!("abcdefghijklmnopqrs (1)"));
validate!(&mut pager, 25, L!("abcdefghijklmnopqrs (1)"));
validate!(&mut pager, 24, L!("abcdefghijklmnopqrs (1)"));
@ -177,7 +177,7 @@ add_test!("test_pager_layout", || {
StringFuzzyMatch::exact_match(),
CompleteFlags::default(),
)];
pager.set_completions(&c3s);
pager.set_completions(&c3s, true);
validate!(&mut pager, 26, L!("abcdefghijklmnopqrst"));
validate!(&mut pager, 25, L!("abcdefghijklmnopqrst"));
validate!(&mut pager, 24, L!("abcdefghijklmnopqrst"));

View file

@ -1209,7 +1209,7 @@ void reader_data_t::fill_history_pager(history_pager_invocation_t why,
}
shared_this->pager.set_extra_progress_text(
result.have_more_results ? _(L"Search again for more results") : L"");
shared_this->pager.set_completions(*result.matched_commands);
shared_this->pager.set_completions(*result.matched_commands, false);
if (why == history_pager_invocation_t::Refresh) {
pager.set_selected_completion_index(*old_pager_index);
pager_selection_changed();
@ -2290,7 +2290,7 @@ bool reader_data_t::handle_completions(const completion_list_t &comp, size_t tok
// Update the pager data.
pager.set_prefix(prefix, true);
pager.set_completions(surviving_completions);
pager.set_completions(surviving_completions, true);
// Modify the command line to reflect the new pager.
pager_selection_changed();
return false;