Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/shell32/autocomplete.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c index 236ba15..b9ea68f 100644 --- a/dlls/shell32/autocomplete.c +++ b/dlls/shell32/autocomplete.c @@ -103,11 +103,16 @@ static void set_text_and_selection(IAutoCompleteImpl *ac, HWND hwnd, WCHAR *text CallWindowProcW(proc, hwnd, EM_SETSEL, start, end); }
-static int enumerate_strings_cmpfn(const void *a, const void *b) +static int sort_strs_cmpfn(const void *a, const void *b) { return strcmpiW(*(WCHAR* const*)a, *(WCHAR* const*)b); }
+static void sort_strs(WCHAR **strs, UINT numstrs) +{ + qsort(strs, numstrs, sizeof(*strs), sort_strs_cmpfn); +} + /* Enumerate all of the strings and sort them in the internal list.
@@ -140,7 +145,7 @@ static void enumerate_strings(IAutoCompleteImpl *ac) { strs = tmp; if (cur > 0) - qsort(strs, cur, sizeof(*strs), enumerate_strings_cmpfn); + sort_strs(strs, cur);
ac->enum_strs = strs; ac->enum_strs_num = cur;
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/shell32/autocomplete.c | 148 ++++++++++++++++++++++++++++++++---- 1 file changed, 132 insertions(+), 16 deletions(-)
diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c index b9ea68f..9292eec 100644 --- a/dlls/shell32/autocomplete.c +++ b/dlls/shell32/autocomplete.c @@ -22,7 +22,6 @@ /* TODO: - implement ACO_SEARCH style - - implement ACO_FILTERPREFIXES style - implement ACO_RTLREADING style - implement ACO_WORD_FILTER style */ @@ -81,6 +80,13 @@ enum autoappend_flag autoappend_flag_displayempty };
+enum prefix_filtering +{ + prefix_filtering_none = 0, /* no prefix filtering (raw search) */ + prefix_filtering_protocol, /* filter common protocol (e.g. http://) */ + prefix_filtering_all /* filter all common prefixes (protocol & www. ) */ +}; + static const WCHAR autocomplete_propertyW[] = {'W','i','n','e',' ','A','u','t','o', 'c','o','m','p','l','e','t','e',' ', 'c','o','n','t','r','o','l',0}; @@ -103,14 +109,98 @@ static void set_text_and_selection(IAutoCompleteImpl *ac, HWND hwnd, WCHAR *text CallWindowProcW(proc, hwnd, EM_SETSEL, start, end); }
-static int sort_strs_cmpfn(const void *a, const void *b) +static inline WCHAR *filter_protocol(WCHAR *str) +{ + static const WCHAR http[] = {'h','t','t','p'}; + + if (!strncmpW(str, http, ARRAY_SIZE(http))) + { + str += ARRAY_SIZE(http); + str += (*str == 's'); /* https */ + if (str[0] == ':' && str[1] == '/' && str[2] == '/') + return str + 3; + } + return NULL; +} + +static inline WCHAR *filter_www(WCHAR *str) +{ + static const WCHAR www[] = {'w','w','w','.'}; + + if (!strncmpW(str, www, ARRAY_SIZE(www))) + return str + ARRAY_SIZE(www); + return NULL; +} + +/* + Get the prefix filtering based on text, for example if text's prefix + is a protocol, then we return none because we actually filter nothing +*/ +static enum prefix_filtering get_text_prefix_filtering(const WCHAR *text) +{ + /* Convert to lowercase to perform case insensitive filtering, + using the longest possible prefix as the size of the buffer */ + WCHAR buf[sizeof("https://")]; + UINT i; + + for (i = 0; i < ARRAY_SIZE(buf) - 1 && text[i]; i++) + buf[i] = tolowerW(text[i]); + buf[i] = '\0'; + + if (filter_protocol(buf)) return prefix_filtering_none; + if (filter_www(buf)) return prefix_filtering_protocol; + return prefix_filtering_all; +} + +/* + Filter the prefix of str based on the value of pfx_filter + This is used in sorting, so it's more performance sensitive +*/ +static WCHAR *filter_str_prefix(WCHAR *str, enum prefix_filtering pfx_filter) +{ + WCHAR *p = str; + + if (pfx_filter == prefix_filtering_none) return str; + if ((p = filter_protocol(str))) str = p; + + if (pfx_filter == prefix_filtering_protocol) return str; + if ((p = filter_www(str))) str = p; + + return str; +} + +static inline int sort_strs_cmpfn_impl(WCHAR *a, WCHAR *b, enum prefix_filtering pfx_filter) +{ + WCHAR *str1 = filter_str_prefix(a, pfx_filter); + WCHAR *str2 = filter_str_prefix(b, pfx_filter); + return strcmpiW(str1, str2); +} + +static int sort_strs_cmpfn_none(const void *a, const void *b) +{ + return sort_strs_cmpfn_impl(*(WCHAR* const*)a, *(WCHAR* const*)b, prefix_filtering_none); +} + +static int sort_strs_cmpfn_protocol(const void *a, const void *b) +{ + return sort_strs_cmpfn_impl(*(WCHAR* const*)a, *(WCHAR* const*)b, prefix_filtering_protocol); +} + +static int sort_strs_cmpfn_all(const void *a, const void *b) { - return strcmpiW(*(WCHAR* const*)a, *(WCHAR* const*)b); + return sort_strs_cmpfn_impl(*(WCHAR* const*)a, *(WCHAR* const*)b, prefix_filtering_all); }
-static void sort_strs(WCHAR **strs, UINT numstrs) +static int (*const sort_strs_cmpfn[])(const void*, const void*) = +{ + sort_strs_cmpfn_none, + sort_strs_cmpfn_protocol, + sort_strs_cmpfn_all +}; + +static void sort_strs(WCHAR **strs, UINT numstrs, enum prefix_filtering pfx_filter) { - qsort(strs, numstrs, sizeof(*strs), sort_strs_cmpfn); + qsort(strs, numstrs, sizeof(*strs), sort_strs_cmpfn[pfx_filter]); }
/* @@ -119,7 +209,7 @@ static void sort_strs(WCHAR **strs, UINT numstrs) We don't free the enumerated strings (except on error) to avoid needless copies, until the next reset (or the object itself is destroyed) */ -static void enumerate_strings(IAutoCompleteImpl *ac) +static void enumerate_strings(IAutoCompleteImpl *ac, enum prefix_filtering pfx_filter) { UINT cur = 0, array_size = 1024; LPOLESTR *strs = NULL, *tmp; @@ -145,7 +235,7 @@ static void enumerate_strings(IAutoCompleteImpl *ac) { strs = tmp; if (cur > 0) - sort_strs(strs, cur); + sort_strs(strs, cur, pfx_filter);
ac->enum_strs = strs; ac->enum_strs_num = cur; @@ -159,14 +249,14 @@ fail: }
static UINT find_matching_enum_str(IAutoCompleteImpl *ac, UINT start, WCHAR *text, - UINT len, int direction) + UINT len, enum prefix_filtering pfx_filter, int direction) { WCHAR **strs = ac->enum_strs; UINT index = ~0, a = start, b = ac->enum_strs_num; while (a < b) { UINT i = (a + b - 1) / 2; - int cmp = strncmpiW(text, strs[i], len); + int cmp = strncmpiW(text, filter_str_prefix(strs[i], pfx_filter), len); if (cmp == 0) { index = i; @@ -406,7 +496,8 @@ static void autoappend_str(IAutoCompleteImpl *ac, WCHAR *text, UINT len, WCHAR * }
static BOOL display_matching_strs(IAutoCompleteImpl *ac, WCHAR *text, UINT len, - HWND hwnd, enum autoappend_flag flag) + enum prefix_filtering pfx_filter, HWND hwnd, + enum autoappend_flag flag) { /* Return FALSE if we need to hide the listbox */ WCHAR **str = ac->enum_strs; @@ -416,17 +507,17 @@ static BOOL display_matching_strs(IAutoCompleteImpl *ac, WCHAR *text, UINT len, /* Windows seems to disable autoappend if ACO_NOPREFIXFILTERING is set */ if (!(ac->options & ACO_NOPREFIXFILTERING) && len) { - start = find_matching_enum_str(ac, 0, text, len, -1); + start = find_matching_enum_str(ac, 0, text, len, pfx_filter, -1); if (start == ~0) return (ac->options & ACO_AUTOSUGGEST) ? FALSE : TRUE;
if (flag == autoappend_flag_yes) - autoappend_str(ac, text, len, str[start], hwnd); + autoappend_str(ac, text, len, filter_str_prefix(str[start], pfx_filter), hwnd); if (!(ac->options & ACO_AUTOSUGGEST)) return TRUE;
/* Find the index beyond the last string that matches */ - end = find_matching_enum_str(ac, start + 1, text, len, 1); + end = find_matching_enum_str(ac, start + 1, text, len, pfx_filter, 1); end = (end == ~0 ? start : end) + 1; } else @@ -450,10 +541,26 @@ static BOOL display_matching_strs(IAutoCompleteImpl *ac, WCHAR *text, UINT len, return TRUE; }
+static enum prefix_filtering setup_prefix_filtering(IAutoCompleteImpl *ac, const WCHAR *text) +{ + enum prefix_filtering pfx_filter; + if (!(ac->options & ACO_FILTERPREFIXES)) return prefix_filtering_none; + + pfx_filter = get_text_prefix_filtering(text); + if (!ac->enum_strs) return pfx_filter; + + /* If the prefix filtering is different, re-sort the filtered strings */ + if (pfx_filter != get_text_prefix_filtering(ac->txtbackup)) + sort_strs(ac->enum_strs, ac->enum_strs_num, pfx_filter); + + return pfx_filter; +} + static void autocomplete_text(IAutoCompleteImpl *ac, HWND hwnd, enum autoappend_flag flag) { WCHAR *text; BOOL expanded = FALSE; + enum prefix_filtering pfx_filter; UINT size, len = SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0);
if (flag != autoappend_flag_displayempty && len == 0) @@ -477,10 +584,12 @@ static void autocomplete_text(IAutoCompleteImpl *ac, HWND hwnd, enum autoappend_ flag = autoappend_flag_no; expanded = aclist_expand(ac, text); } + pfx_filter = setup_prefix_filtering(ac, text); + if (expanded || !ac->enum_strs) { if (!expanded) IEnumString_Reset(ac->enumstr); - enumerate_strings(ac); + enumerate_strings(ac, pfx_filter); }
/* Set txtbackup to point to text itself (which must not be released), @@ -488,7 +597,7 @@ static void autocomplete_text(IAutoCompleteImpl *ac, HWND hwnd, enum autoappend_ heap_free(ac->txtbackup); ac->txtbackup = text;
- if (!display_matching_strs(ac, text, len, hwnd, flag)) + if (!display_matching_strs(ac, text, len, pfx_filter, hwnd, flag)) hide_listbox(ac, ac->hwndListBox, FALSE); }
@@ -832,7 +941,6 @@ static HRESULT WINAPI IAutoComplete2_fnInit( This, hwndEdit, punkACL, debugstr_w(pwzsRegKeyPath), debugstr_w(pwszQuickComplete));
if (This->options & ACO_SEARCH) FIXME(" ACO_SEARCH not supported\n"); - if (This->options & ACO_FILTERPREFIXES) FIXME(" ACO_FILTERPREFIXES not supported\n"); if (This->options & ACO_RTLREADING) FIXME(" ACO_RTLREADING not supported\n"); if (This->options & ACO_WORD_FILTER) FIXME(" ACO_WORD_FILTER not supported\n");
@@ -965,6 +1073,7 @@ static HRESULT WINAPI IAutoComplete2_fnSetOptions( DWORD dwFlag) { IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface); + DWORD changed = This->options ^ dwFlag; HRESULT hr = S_OK;
TRACE("(%p) -> (0x%x)\n", This, dwFlag); @@ -976,6 +1085,13 @@ static HRESULT WINAPI IAutoComplete2_fnSetOptions( else if (!(This->options & ACO_AUTOSUGGEST) && This->hwndListBox) hide_listbox(This, This->hwndListBox, TRUE);
+ /* If ACO_FILTERPREFIXES changed we might have to reset the enumerator */ + if ((changed & ACO_FILTERPREFIXES) && This->txtbackup) + { + if (get_text_prefix_filtering(This->txtbackup) != prefix_filtering_none) + IAutoCompleteDropDown_ResetEnumerator(&This->IAutoCompleteDropDown_iface); + } + return hr; }
Signed-off-by: Huw Davies huw@codeweavers.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/shell32/tests/autocomplete.c | 172 ++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+)
diff --git a/dlls/shell32/tests/autocomplete.c b/dlls/shell32/tests/autocomplete.c index ad7eb6a..33a5e64 100644 --- a/dlls/shell32/tests/autocomplete.c +++ b/dlls/shell32/tests/autocomplete.c @@ -450,6 +450,50 @@ static void dispatch_messages(void) } }
+#define check_dropdown(acdropdown, hwnd_edit, list, list_num) check_dropdown_(__FILE__, __LINE__, acdropdown, hwnd_edit, list, list_num) +static void check_dropdown_(const char *file, UINT line, IAutoCompleteDropDown *acdropdown, HWND hwnd_edit, WCHAR **list, UINT list_num) +{ + UINT i; + DWORD flags = 0; + LPWSTR str; + HRESULT hr; + + hr = IAutoCompleteDropDown_GetDropDownStatus(acdropdown, &flags, &str); + ok_(file, line)(hr == S_OK, "IAutoCompleteDropDown_GetDropDownStatus failed: %x\n", hr); + if (hr != S_OK) return; + if (list_num) ok_(file, line)(flags & ACDD_VISIBLE, "AutoComplete DropDown not visible\n"); + else + { + ok_(file, line)(!(flags & ACDD_VISIBLE), "AutoComplete DropDown visible\n"); + return; + } + ok_(file, line)(str == NULL, "Expected (null), got %s\n", wine_dbgstr_w(str)); + if (str) + { + CoTaskMemFree(str); + return; + } + + for (i = 0; i <= list_num; i++) + { + flags = 0; + SendMessageW(hwnd_edit, WM_KEYDOWN, VK_DOWN, 0); + SendMessageW(hwnd_edit, WM_KEYUP, VK_DOWN, 0xc0000000); + hr = IAutoCompleteDropDown_GetDropDownStatus(acdropdown, &flags, &str); + ok_(file, line)(hr == S_OK, "IAutoCompleteDropDown_GetDropDownStatus failed: %x\n", hr); + ok_(file, line)(flags & ACDD_VISIBLE, "AutoComplete DropDown not visible\n"); + if (hr == S_OK) + { + if (i < list_num) + ok_(file, line)(str && !lstrcmpW(list[i], str), "Expected %s, got %s\n", + wine_dbgstr_w(list[i]), wine_dbgstr_w(str)); + else + ok_(file, line)(str == NULL, "Expected (null), got %s\n", wine_dbgstr_w(str)); + } + if (str) CoTaskMemFree(str); + } +} + static void test_aclist_expand(HWND hwnd_edit, void *enumerator) { struct string_enumerator *obj = (struct string_enumerator*)enumerator; @@ -504,6 +548,132 @@ static void test_aclist_expand(HWND hwnd_edit, void *enumerator) ok(obj->num_resets == 5, "Expected 5 resets, got %u\n", obj->num_resets); }
+static void test_prefix_filtering(HWND hwnd_edit) +{ + static WCHAR htt[] = {'h','t','t',0}; + static WCHAR www[] = {'w','w','w','.',0}; + static WCHAR str0[] = {'w','w','w','.','a','x',0}; + static WCHAR str1[] = {'h','t','t','p','s',':','/','/','w','w','w','.','a','c',0}; + static WCHAR str2[] = {'a','a',0}; + static WCHAR str3[] = {'a','b',0}; + static WCHAR str4[] = {'h','t','t','p',':','/','/','a','0',0}; + static WCHAR str5[] = {'h','t','t','p','s',':','/','/','h','t','a',0}; + static WCHAR str6[] = {'h','f','o','o',0}; + static WCHAR str7[] = {'h','t','t','p',':','/','/','w','w','w','.','a','d','d',0}; + static WCHAR str8[] = {'w','w','w','.','w','w','w','.','?',0}; + static WCHAR str9[] = {'h','t','t','p',':','/','/','a','b','c','.','a','a','.','c','o','m',0}; + static WCHAR str10[]= {'f','t','p',':','/','/','a','b','c',0}; + static WCHAR str11[]= {'f','i','l','e',':','/','/','a','a',0}; + static WCHAR str12[]= {'f','t','p',':','/','/','w','w','w','.','a','a',0}; + static WCHAR *suggestions[] = { str0, str1, str2, str3, str4, str5, str6, str7, str8, str9, str10, str11, str12 }; + static WCHAR *sorted1[] = { str4, str2, str3, str9, str1, str7, str0 }; + static WCHAR *sorted2[] = { str3, str9 }; + static WCHAR *sorted3[] = { str1, str7, str0 }; + static WCHAR *sorted4[] = { str6, str5 }; + static WCHAR *sorted5[] = { str5 }; + static WCHAR *sorted6[] = { str4, str9 }; + static WCHAR *sorted7[] = { str11, str10, str12 }; + IUnknown *enumerator; + IAutoComplete2 *autocomplete; + IAutoCompleteDropDown *acdropdown; + WCHAR buffer[20]; + HRESULT hr; + + hr = CoCreateInstance(&CLSID_AutoComplete, NULL, CLSCTX_INPROC_SERVER, &IID_IAutoComplete2, (void**)&autocomplete); + ok(hr == S_OK, "CoCreateInstance failed: %x\n", hr); + + hr = IAutoComplete2_QueryInterface(autocomplete, &IID_IAutoCompleteDropDown, (LPVOID*)&acdropdown); + ok(hr == S_OK, "No IAutoCompleteDropDown interface: %x\n", hr); + + string_enumerator_create((void**)&enumerator, suggestions, ARRAY_SIZE(suggestions)); + + hr = IAutoComplete2_SetOptions(autocomplete, ACO_FILTERPREFIXES | ACO_AUTOSUGGEST | ACO_AUTOAPPEND); + ok(hr == S_OK, "IAutoComplete2_SetOptions failed: %x\n", hr); + hr = IAutoComplete2_Init(autocomplete, hwnd_edit, enumerator, NULL, NULL); + ok(hr == S_OK, "IAutoComplete_Init failed: %x\n", hr); + + SendMessageW(hwnd_edit, EM_SETSEL, 0, -1); + SendMessageW(hwnd_edit, WM_CHAR, 'a', 1); + dispatch_messages(); + SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + ok(lstrcmpW(str4 + 7, buffer) == 0, "Expected %s, got %s\n", wine_dbgstr_w(str4 + 7), wine_dbgstr_w(buffer)); + check_dropdown(acdropdown, hwnd_edit, sorted1, ARRAY_SIZE(sorted1)); + + SendMessageW(hwnd_edit, EM_SETSEL, 0, -1); + SendMessageW(hwnd_edit, WM_CHAR, 'a', 1); + SendMessageW(hwnd_edit, WM_CHAR, 'b', 1); + dispatch_messages(); + SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + ok(lstrcmpW(str3, buffer) == 0, "Expected %s, got %s\n", wine_dbgstr_w(str3), wine_dbgstr_w(buffer)); + check_dropdown(acdropdown, hwnd_edit, sorted2, ARRAY_SIZE(sorted2)); + SendMessageW(hwnd_edit, EM_SETSEL, 0, -1); + SendMessageW(hwnd_edit, WM_CHAR, 'a', 1); + SendMessageW(hwnd_edit, WM_CHAR, 'b', 1); + SendMessageW(hwnd_edit, WM_CHAR, 'c', 1); + dispatch_messages(); + SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + ok(lstrcmpW(str9 + 7, buffer) == 0, "Expected %s, got %s\n", wine_dbgstr_w(str9 + 7), wine_dbgstr_w(buffer)); + + SendMessageW(hwnd_edit, WM_SETTEXT, 0, (LPARAM)www); + SendMessageW(hwnd_edit, EM_SETSEL, ARRAY_SIZE(www) - 1, ARRAY_SIZE(www) - 1); + SendMessageW(hwnd_edit, WM_CHAR, 'a', 1); + dispatch_messages(); + SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + ok(lstrcmpW(str1 + 8, buffer) == 0, "Expected %s, got %s\n", wine_dbgstr_w(str1 + 8), wine_dbgstr_w(buffer)); + check_dropdown(acdropdown, hwnd_edit, sorted3, ARRAY_SIZE(sorted3)); + SendMessageW(hwnd_edit, WM_SETTEXT, 0, (LPARAM)www); + SendMessageW(hwnd_edit, EM_SETSEL, ARRAY_SIZE(www) - 1, ARRAY_SIZE(www) - 1); + SendMessageW(hwnd_edit, WM_CHAR, 'w', 1); + dispatch_messages(); + SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + ok(lstrcmpW(str8, buffer) == 0, "Expected %s, got %s\n", wine_dbgstr_w(str8), wine_dbgstr_w(buffer)); + + SendMessageW(hwnd_edit, EM_SETSEL, 0, -1); + SendMessageW(hwnd_edit, WM_CHAR, 'h', 1); + dispatch_messages(); + SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + ok(lstrcmpW(str6, buffer) == 0, "Expected %s, got %s\n", wine_dbgstr_w(str6), wine_dbgstr_w(buffer)); + check_dropdown(acdropdown, hwnd_edit, sorted4, ARRAY_SIZE(sorted4)); + SendMessageW(hwnd_edit, WM_CHAR, 't', 1); + SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + ok(lstrcmpW(str5 + 8, buffer) == 0, "Expected %s, got %s\n", wine_dbgstr_w(str5 + 8), wine_dbgstr_w(buffer)); + check_dropdown(acdropdown, hwnd_edit, sorted5, ARRAY_SIZE(sorted5)); + SendMessageW(hwnd_edit, WM_CHAR, 't', 1); + SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + ok(lstrcmpW(htt, buffer) == 0, "Expected %s, got %s\n", wine_dbgstr_w(htt), wine_dbgstr_w(buffer)); + check_dropdown(acdropdown, hwnd_edit, NULL, 0); + SendMessageW(hwnd_edit, WM_CHAR, 'p', 1); + SendMessageW(hwnd_edit, WM_CHAR, ':', 1); + SendMessageW(hwnd_edit, WM_CHAR, '/', 1); + SendMessageW(hwnd_edit, WM_CHAR, '/', 1); + SendMessageW(hwnd_edit, WM_CHAR, 'a', 1); + dispatch_messages(); + SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + ok(lstrcmpW(str4, buffer) == 0, "Expected %s, got %s\n", wine_dbgstr_w(str4), wine_dbgstr_w(buffer)); + check_dropdown(acdropdown, hwnd_edit, sorted6, ARRAY_SIZE(sorted6)); + SendMessageW(hwnd_edit, EM_SETSEL, 0, 2); + SendMessageW(hwnd_edit, WM_CHAR, 'H', 1); + dispatch_messages(); + check_dropdown(acdropdown, hwnd_edit, NULL, 0); + SendMessageW(hwnd_edit, WM_CHAR, 't', 1); + dispatch_messages(); + check_dropdown(acdropdown, hwnd_edit, sorted6, ARRAY_SIZE(sorted6)); + + SendMessageW(hwnd_edit, EM_SETSEL, 0, -1); + SendMessageW(hwnd_edit, WM_CHAR, 'F', 1); + dispatch_messages(); + SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + check_dropdown(acdropdown, hwnd_edit, sorted7, ARRAY_SIZE(sorted7)); + SendMessageW(hwnd_edit, WM_CHAR, 'i', 1); + SendMessageW(hwnd_edit, WM_CHAR, 'L', 1); + SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); + check_dropdown(acdropdown, hwnd_edit, sorted7, 1); + + IAutoCompleteDropDown_Release(acdropdown); + IAutoComplete2_Release(autocomplete); + IUnknown_Release(enumerator); +} + static void test_custom_source(void) { static WCHAR str_alpha[] = {'t','e','s','t','1',0}; @@ -618,6 +788,8 @@ static void test_custom_source(void) ok(obj->num_resets == 1, "Expected 1 reset, got %u\n", obj->num_resets); IAutoCompleteDropDown_Release(acdropdown);
+ test_prefix_filtering(hwnd_edit); + ShowWindow(hMainWnd, SW_HIDE); DestroyWindow(hwnd_edit); }
Signed-off-by: Huw Davies huw@codeweavers.com
An autocomplete object can be destroyed and detached from the edit control and still survive, if there are still references to it (even though it's useless).
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com ---
I'm not aware of anything that depends on this, I just thought about it and realized it was wrong in such corner cases. This is the correct approach. Sorry for the oversight.
dlls/shell32/autocomplete.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c index 9292eec..6c013a8 100644 --- a/dlls/shell32/autocomplete.c +++ b/dlls/shell32/autocomplete.c @@ -1181,7 +1181,7 @@ static HRESULT WINAPI IAutoCompleteDropDown_fnResetEnumerator(
TRACE("(%p)\n", This);
- if (This->initialized) + if (This->hwndEdit) { free_enum_strs(This); if ((This->options & ACO_AUTOSUGGEST) && IsWindowVisible(This->hwndListBox))
Signed-off-by: Huw Davies huw@codeweavers.com