-
Notifications
You must be signed in to change notification settings - Fork 435
Description
Description
Spun off from the following Chromium Issue (and the discussion in Mozc).
Currently Mozc ignores surrounding text if the corresponding ITfContext is a transitory context.
mozc/src/win32/tip/tip_keyevent_handler.cc
Lines 281 to 299 in 18c5945
| void FillMozcContextForOnKey(TipTextService *text_service, ITfContext *context, | |
| Context *mozc_context) { | |
| FillMozcContextCommon(text_service, context, mozc_context); | |
| TipSurroundingTextInfo info; | |
| if (!TipSurroundingText::Get(text_service, context, &info)) { | |
| return; | |
| } | |
| if (info.is_transitory) { | |
| // Ignore transitory context as it may not contain correct | |
| // surrounding text info. | |
| return; | |
| } | |
| if (info.has_preceding_text) { | |
| mozc_context->set_preceding_text(WideToUtf8(info.preceding_text)); | |
| } | |
| if (info.has_following_text) { | |
| mozc_context->set_following_text(WideToUtf8(info.following_text)); | |
| } | |
| } |
mozc/src/win32/tip/tip_surrounding_text.cc
Lines 77 to 78 in 18c5945
| result_.is_transitory = | |
| ((status.dwStaticFlags & TF_SS_TRANSITORY) == TF_SS_TRANSITORY); |
I don't fully remember why I added this check, but it seems to make some sense when Mozc is interacting with legacy Win32 APP that does not use TSF (Text Services Framework) and common controls (EditText and RichEdit), where TSF API always returns an empty preceding/following text. Apps like Hidemaru and Sakura Editor fall into this category. If we mechanically removed the above check, mozc_tip{32,64}.dll would start reporting both the preceding and following texts are empty to mozc_server.exe even if they are not.
At the same time, removing TS_SS_TRANSITORY from Chromium is known to break several existing IMEs including Keyman.
Let's try to figure out a way to support surrounding text on Chromium-based apps in the Mozc side without reporting wrong surrounding text on other IMM32-based legacy apps.
Steps to reproduce
- Open
data:text/html,<textarea>1</textarea>with Google Chrome 136.0.7103.114. - Click the text area and move the cursor to the end.
- Select and enable Mozc
- Type hiki
Expected behavior
At the step 4, "匹" is suggested.
Actual behavior
At the step 4, "引き" is suggested.
Version or commit-id
Environment
- OS: Windows 11 24H2