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
This commit is contained in:
parent
65de17ece4
commit
b8bad3549d
Notes:
blender-bot
2023-02-14 07:45:38 +01:00
Referenced by issue #93519, Auto-complete not working for ID templates
|
@ -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! */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue