diff options
author | Hans Goudey <h.goudey@me.com> | 2021-03-05 23:45:09 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-03-05 23:45:09 +0300 |
commit | becc36cce5248417fe4f626dedb50804c0e0eb1d (patch) | |
tree | 92c4433e0aa67ed8dc324976cde5230d66eaae9a /source/blender | |
parent | 4addcf1efcd6d6cc4d72a730bd88f4b89d2f1a8d (diff) |
Geometry Nodes: Sort attribute search items when menu opens
Because the search didn't run when the menu first opens, the attributes
appeared in a different order than after you typed anything into the
search field. This commit instead runs the search when the menu
is first opened, but it only sorts items without filtering.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_node/node_geometry_attribute_search.cc | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/source/blender/editors/space_node/node_geometry_attribute_search.cc b/source/blender/editors/space_node/node_geometry_attribute_search.cc index 982c57eb3ec..b03346577a8 100644 --- a/source/blender/editors/space_node/node_geometry_attribute_search.cc +++ b/source/blender/editors/space_node/node_geometry_attribute_search.cc @@ -75,15 +75,9 @@ static void attribute_search_update_fn( UI_search_item_add(items, str, (void *)str, ICON_X, 0, 0); } - /* Skip the filter when the menu is first opened, so all of the items are visible. */ - if (is_first) { - for (const std::string &attribute_name : attribute_name_hints) { - /* Just use the pointer to the name string as the search data, - * since it's not used anyway but we need a pointer. */ - UI_search_item_add(items, attribute_name.c_str(), (void *)&attribute_name, ICON_NONE, 0, 0); - } - return; - } + /* Don't filter when the menu is first opened, but still run the search + * so the items are in the same order they will appear in while searching. */ + const char *string = is_first ? "" : str; StringSearch *search = BLI_string_search_new(); for (const std::string &attribute_name : attribute_name_hints) { @@ -91,7 +85,7 @@ static void attribute_search_update_fn( } std::string **filtered_items; - const int filtered_amount = BLI_string_search_query(search, str, (void ***)&filtered_items); + const int filtered_amount = BLI_string_search_query(search, string, (void ***)&filtered_items); for (const int i : IndexRange(filtered_amount)) { std::string *item = filtered_items[i]; |