Improve formatting of TreeSearch

This commit is contained in:
Alexander Montag 2024-09-29 16:43:48 +00:00
parent f7d546fc3c
commit e8de3adc50
No known key found for this signature in database
GPG Key ID: 07FE50B35A2B7524
1 changed files with 6 additions and 4 deletions

View File

@ -356,12 +356,13 @@ void TreeSearch::_select_next_match() {
if (matching_entries.size() == 0) {
return;
}
TreeItem *selected = tree_reference->get_selected(); // we care about a single item here.
TreeItem *selected = tree_reference->get_selected();
if (!selected) {
_select_first_match();
return;
}
// find [selected_idx] among ordered_tree_items
int selected_idx = -1;
for (int i = 0; i < ordered_tree_items.size(); i++) {
if (ordered_tree_items[i] == selected) {
@ -370,7 +371,7 @@ void TreeSearch::_select_next_match() {
}
}
// find the best fitting entry.
// find first entry after [selected_idx].
for (int i = MAX(0, selected_idx) + 1; i < ordered_tree_items.size(); i++) {
TreeItem *item = ordered_tree_items[i];
if (_vector_has_bsearch(matching_entries, item)) {
@ -378,7 +379,8 @@ void TreeSearch::_select_next_match() {
return;
}
}
_select_first_match(); // wrap around.
// wrap around.
_select_first_match();
}
template <typename T>
@ -511,7 +513,7 @@ TreeSearchPanel::TreeSearchPanel() {
set_visible(false);
}
TreeSearch::TreeSearchMode TreeSearchPanel::get_search_mode() const{
TreeSearch::TreeSearchMode TreeSearchPanel::get_search_mode() const {
if (!check_button_filter_highlight || !check_button_filter_highlight->is_pressed()) {
return TreeSearch::TreeSearchMode::HIGHLIGHT;
}