Repository navigation
fix(composer): 修复中文输入法下输入斜杠出现 /、 的问题 - #1967
Conversation
Normalizing the leading ideographic comma during pre-edit repaints text nodes still owned by the IME, allowing its final commit to append a second character. Preserve pre-edit text and normalize the settled draft while remembering whether the composition began empty. Keep missing-compositionend recovery intact and cover the native Chromium composition sequence, caret position, cancellation, and draft replacement.
muzimu217
left a comment
There was a problem hiding this comment.
The approach is the right one for this class of bug: defer the slash-alias conversion until composition ends, and remember whether the draft was empty when the composition started rather than when it finished. That second half is what makes 、 in the middle of existing text stay literal while / at the start still opens the menu, and the draftKey guard on the ref means a session switch mid-composition cannot apply the decision to a different draft.
Driving composition through CDP in scripts/e2e-composer-ime-stack.mjs is the part that makes this reviewable at all — alias commit, ordinary Chinese text, cancellation, draft replacement, completion acceptance and lost-end recovery are exactly the cases a synthetic input event cannot exercise, because the duplicate comes from the IME appending to a text node the app rewrote. Noting in the spec that sending and a physical OS IME stay manual is honest and correct.
One thing I would want to see stated, because it is the ordering that bites in this area: Chromium fires compositionend and then a final input with isComposing === false (some IMEs the other way around). The fix converts at compositionend, so the question is whether that trailing input can re-run the conversion on already-converted text. If the CDP probe asserts the final DOM and draft after the complete compositionstart → input → compositionend → input sequence — which is what a real IME produces — then it is covered and this is just a note for the next reader. If the probe stops at compositionend, adding the trailing input would pin the double-conversion case explicitly.
The isComposing plumbing into onInput(source, start, native.isComposing) is a clean signature change: it keeps the decision at the layer that owns the draft instead of having the input component guess.
|
独立审查通过,准备合入
|
Fixes #1966
问题
在空白输入框中使用中文输入法按一次
/,最终可能生成/、,且编辑区 DOM 和草稿状态均包含重复字符。#1966 报告的环境为 Windows 11、微信输入法 2.1.2。该问题也已在包含 #1248 的上游 main 提交 79fb39b 中隔离复现。
原逻辑在输入法仍处于组合输入阶段时,就将临时文本
、转换为/,随后重绘编辑区、替换输入法正在操作的文本节点。输入法最终提交时,可能在已有的/后追加、。修复
isComposing传递到草稿处理层,组字期间保留临时文本并继续同步草稿,避免提前转换和重绘。compositionend时读取最终文本和光标位置,确保编辑区 DOM 与草稿状态一致。compositionend后菜单冻结的恢复逻辑。修复后,空草稿中的中文输入法斜杠输入最终保留单个
/,并正常触发命令菜单;已有正文中的顿号保持原样。验证
、,等待草稿和布局同步,再提交、。该测试修复前失败,修复后 DOM 与草稿均为单个/。/不再生成/、。