From: Gabriel Ivăncescu Subject: [PATCH 08/17] shell32/autocomplete: Fix going up through the AutoComplete listbox Message-Id: Date: Wed, 5 Sep 2018 19:13:10 +0300 In-Reply-To: <695190c8471230e6a87e237a7c4a86e3281525b8.1536163731.git.gabrielopcode@gmail.com> References: <695190c8471230e6a87e237a7c4a86e3281525b8.1536163731.git.gabrielopcode@gmail.com> When going up past the topmost item in the listbox, go through txtbackup first before wrapping around, just like when going down. This matches Windows behavior. Signed-off-by: Gabriel Ivăncescu --- dlls/shell32/autocomplete.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c index 74728e0..4305f65 100644 --- a/dlls/shell32/autocomplete.c +++ b/dlls/shell32/autocomplete.c @@ -183,14 +183,12 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, goto autocomplete_text; } } else { - INT count; - - count = SendMessageW(This->hwndListBox, LB_GETCOUNT, 0, 0); + INT count = SendMessageW(This->hwndListBox, LB_GETCOUNT, 0, 0); /* Change the selection */ sel = SendMessageW(This->hwndListBox, LB_GETCURSEL, 0, 0); if (wParam == VK_UP) - sel = ((sel-1) < 0) ? count-1 : sel-1; + sel = ((sel-1) < -1) ? count-1 : sel-1; else sel = ((sel+1) >= count) ? -1 : sel+1; SendMessageW(This->hwndListBox, LB_SETCURSEL, sel, 0); -- 1.9.1