From: Gabriel Ivăncescu Subject: [PATCH v2 4/8] shell32/autocomplete: Don't autocomplete at all on most control characters Message-Id: <0d9f77e0aa067a3883af70444ae00efa535bc668.1537444354.git.gabrielopcode@gmail.com> Date: Thu, 20 Sep 2018 14:55:37 +0300 In-Reply-To: References: Most control characters sent via some CTRL+key combination should not autocomplete at all. ^C is one example, where just copying some text should not show the auto-suggestion box (if not visible). ^V is another example, where it is already handled in WM_PASTE, so it has to be a no-op here, else auto-append from WM_PASTE would complete the text and then the ^V autocompletion would remove every other suggestion in the listbox (which is not desirable nor does it match Windows). Signed-off-by: Gabriel Ivăncescu --- Rather than check for ^C and ^V as special cases, I decided to ignore most control characters, with notable exceptions like Backspace and Tab characters (since they actually do something) and the newline stuff in that range. Unfortunately, I can't seem to find a better way. I realize this looks like a hack, but it doesn't seem like there's another way to me. ^C is obvious: there's nothing we can do in WM_COPY (even if we handled it, somehow) because the ^C will still be there waiting to be processed after it. ^V is less obvious. Right now, if you paste something via CTRL+V (instead of right-click -> Paste) and it gets auto-appended, the resulting suggestions will be removed because the autocomplete will happen *twice*. The first time in WM_PASTE (properly) and then in ^V when it will "see" the entire text because of the auto-append from WM_PASTE, and thus removes all the other suggestions. This should not happen. Pasting via right-click obviously does not have this problem, but it is the reason we have to do it in WM_PASTE as well, anyway. This makes ^V have the same behavior as Right-click + Paste. dlls/shell32/autocomplete.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c index ef835b9..92afbe2 100644 --- a/dlls/shell32/autocomplete.c +++ b/dlls/shell32/autocomplete.c @@ -359,6 +359,10 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, return ACEditSubclassProc_KeyDown(This, hwnd, uMsg, wParam, lParam); case WM_CHAR: case WM_UNICHAR: + /* Don't autocomplete at all on most control characters */ + if (wParam < '\b' || (wParam > '\r' && wParam < ' ')) + break; + ret = CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam); autocomplete_text(This, hwnd, (This->options & ACO_AUTOAPPEND) && wParam >= ' ' ? autoappend_flag_yes : autoappend_flag_no); -- 1.9.1