Fix search box losing characters typed through an IME - #1137
Open
xiaoxidashen wants to merge 1 commit into
Open
Conversation
When the paste window opens, focus is on the list control. Committing a string from an IME queues the whole string as a burst of WM_CHAR messages that all carry the list control in pMsg->hwnd. The first character moved focus to the search box, after which the GetFocus() check no longer matched, so the remaining characters were dispatched to the list control's incremental search and lost. Typing without an IME did not show this, because each keystroke's message is generated after the previous one has already moved focus. Key the check on pMsg->hwnd so the whole burst is captured, append rather than overwrite (only the first character of a run clears the box), and place the caret at the end of the text instead of a hardcoded offset.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Open the paste window with the hotkey and type into it with an IME active. Type
abcd, let the IME hold the composition, then press Enter to commit. Onlyareaches the search box —
bcdare silently dropped. Typingabcda second timeworks, because the search box now already has focus.
Cause
When the paste window opens, focus is on the list control. Committing a string
from an IME queues the whole string as a burst of
WM_CHARmessages that allcarry the list control in
pMsg->hwnd.CQPasteWnd::PreTranslateMessagegated the search-box redirect onGetFocus() == m_lstHeader. The first character passed that check and calledm_search.SetFocus(). From the second character on the check no longer matched,so those messages fell through to
DispatchMessage, which routes bypMsg->hwnd— back to the list control, where they were consumed as incrementalsearch.
Typing without an IME hides the bug: each keystroke's message is generated at the
moment the key goes down, by which time the previous character has already moved
focus.
Fix
pMsg->hwndinstead ofGetFocus(), so the whole burst iscaptured no matter where focus has moved.
preserving the "typing in the list starts a new search" behaviour.
SetSel(1, 1)hardcoded offset1, which is wrong as soon as the text is longer than one character.
SetWindowTextis kept rather thanReplaceSelso the existing manualOnSearchEditChange()call still fires exactly once per character —ReplaceSelwould raiseEN_CHANGEand search twice for every keystroke.Testing
Built Release x64 and ran it as the installed Ditto. With an IME active,
abcdtyping and the existing "start typing in the list to search" behaviour are
unchanged.