[PATCH] shell32/autocomplete: Always expand if the enumerator was reset
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> --- Fixes a small and rare issue. This reuses the existing code for minimal changes. A simple test has been included in the patch because it was small enough. dlls/shell32/autocomplete.c | 8 +++++++- dlls/shell32/tests/autocomplete.c | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c index 6c013a8..2cf5588 100644 --- a/dlls/shell32/autocomplete.c +++ b/dlls/shell32/autocomplete.c @@ -435,12 +435,18 @@ static BOOL aclist_expand(IAutoCompleteImpl *ac, WCHAR *txt) { /* call IACList::Expand only when needed, if the new txt and old_txt require different expansions */ - WCHAR c, *p, *last_delim, *old_txt = ac->txtbackup; + static const WCHAR empty[] = { 0 }; + + const WCHAR *old_txt = ac->txtbackup; + WCHAR c, *p, *last_delim; size_t i = 0; /* '/' is allowed as a delim for unix paths */ static const WCHAR delims[] = { '\\', '/', 0 }; + /* always expand if the enumerator was reset */ + if (!ac->enum_strs) old_txt = empty; + /* skip the shared prefix */ while ((c = tolowerW(txt[i])) == tolowerW(old_txt[i])) { diff --git a/dlls/shell32/tests/autocomplete.c b/dlls/shell32/tests/autocomplete.c index 0da164b..b06d652 100644 --- a/dlls/shell32/tests/autocomplete.c +++ b/dlls/shell32/tests/autocomplete.c @@ -494,7 +494,7 @@ static void check_dropdown_(const char *file, UINT line, IAutoCompleteDropDown * } } -static void test_aclist_expand(HWND hwnd_edit, void *enumerator) +static void test_aclist_expand(HWND hwnd_edit, void *enumerator, IAutoCompleteDropDown *acdropdown) { struct string_enumerator *obj = (struct string_enumerator*)enumerator; static WCHAR str1[] = {'t','e','s','t',0}; @@ -502,6 +502,7 @@ static void test_aclist_expand(HWND hwnd_edit, void *enumerator) static WCHAR str2[] = {'t','e','s','t','\\','f','o','o','\\','b','a','r','\\','b','a',0}; static WCHAR str2a[] = {'t','e','s','t','\\','f','o','o','\\','b','a','r','\\',0}; static WCHAR str2b[] = {'t','e','s','t','\\','f','o','o','\\','b','a','r','\\','b','a','z','_','b','b','q','\\',0}; + HRESULT hr; obj->num_resets = 0; ok(obj->num_expand == 0, "Expected 0 expansions, got %u\n", obj->num_expand); @@ -546,6 +547,20 @@ static void test_aclist_expand(HWND hwnd_edit, void *enumerator) dispatch_messages(); ok(obj->num_expand == 4, "Expected 4 expansions, got %u\n", obj->num_expand); ok(obj->num_resets == 5, "Expected 5 resets, got %u\n", obj->num_resets); + SendMessageW(hwnd_edit, WM_SETTEXT, 0, (LPARAM)str1a); + SendMessageW(hwnd_edit, EM_SETSEL, ARRAY_SIZE(str1a) - 1, ARRAY_SIZE(str1a) - 1); + SendMessageW(hwnd_edit, WM_CHAR, 'f', 1); + dispatch_messages(); + ok(obj->num_expand == 5, "Expected 5 expansions, got %u\n", obj->num_expand); + ok(lstrcmpW(obj->last_expand, str1a) == 0, "Expected %s, got %s\n", wine_dbgstr_w(str1a), wine_dbgstr_w(obj->last_expand)); + ok(obj->num_resets == 6, "Expected 6 resets, got %u\n", obj->num_resets); + hr = IAutoCompleteDropDown_ResetEnumerator(acdropdown); + ok(hr == S_OK, "IAutoCompleteDropDown_ResetEnumerator failed: %x\n", hr); + SendMessageW(hwnd_edit, WM_CHAR, 'o', 1); + dispatch_messages(); + ok(obj->num_expand == 6, "Expected 6 expansions, got %u\n", obj->num_expand); + ok(lstrcmpW(obj->last_expand, str1a) == 0, "Expected %s, got %s\n", wine_dbgstr_w(str1a), wine_dbgstr_w(obj->last_expand)); + ok(obj->num_resets == 7, "Expected 7 resets, got %u\n", obj->num_resets); } static void test_prefix_filtering(HWND hwnd_edit) @@ -775,7 +790,7 @@ static void test_custom_source(void) SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer); ok(lstrcmpW(str_aut, buffer) == 0, "Expected %s, got %s\n", wine_dbgstr_w(str_aut), wine_dbgstr_w(buffer)); - test_aclist_expand(hwnd_edit, enumerator); + test_aclist_expand(hwnd_edit, enumerator, acdropdown); obj->num_resets = 0; hr = IAutoCompleteDropDown_ResetEnumerator(acdropdown); -- 2.19.1
participants (1)
-
Gabriel Ivăncescu