Commit: b8bad3549dcef0b761708ef9cc1f814ebedb3106 Author: Azeem Bande-Ali Date: Thu Dec 9 11:09:50 2021 +0100 Branches: master https://developer.blender.org/rBb8bad3549dcef0b761708ef9cc1f814ebedb3106
Fix T93519: handle prefix names in autocompletes Autocomplete entires keep track of the length of the prefix in `name_prefix_offset`. However, the name matching logic was comparing the string including the prefix which resulted in tab-completion not working (when the user didn't also type in the prefix, typically two whitespaces). This is fixed by passing in a char pointer after the end of the prefix. Additionally, some searchbox logic is moved. Previously, `ui_searchbox_apply` would clear the entry which would mean that `ui_searchbox_find_index` would never succeed. Now the search box is only cleared if no match was found. Differential Revision: https://developer.blender.org/D13483 =================================================================== M source/blender/editors/interface/interface_handlers.c M source/blender/editors/interface/interface_region_search.cc =================================================================== diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 637ab822067..f947572f41b 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3551,6 +3551,12 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data) if ((ui_searchbox_apply(but, data->searchbox) == false) && (ui_searchbox_find_index(data->searchbox, but->editstr) == -1) && !but_search->results_are_suggestions) { + + if (but->flag & UI_BUT_VALUE_CLEAR) { + /* It is valid for _VALUE_CLEAR flavor to have no active element + * (it's a valid way to unlink). */ + but->editstr[0] = '\0'; + } data->cancel = true; /* ensure menu (popup) too is closed! */ diff --git a/source/blender/editors/interface/interface_region_search.cc b/source/blender/editors/interface/interface_region_search.cc index 5b30e922a67..f4c99fb3c16 100644 --- a/source/blender/editors/interface/interface_region_search.cc +++ b/source/blender/editors/interface/interface_region_search.cc @@ -115,7 +115,7 @@ bool UI_search_item_add(uiSearchItems *items, { /* hijack for autocomplete */ if (items->autocpl) { - UI_autocomplete_update_name(items->autocpl, name); + UI_autocomplete_update_name(items->autocpl, name + name_prefix_offset); return true; } @@ -313,13 +313,6 @@ bool ui_searchbox_apply(uiBut *but, ARegion *region) return true; } - if (but->flag & UI_BUT_VALUE_CLEAR) { - /* It is valid for _VALUE_CLEAR flavor to have no active element - * (it's a valid way to unlink). */ - but->editstr[0] = '\0'; - - return true; - } return false; } _______________________________________________ Bf-blender-cvs mailing list [email protected] List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
