Repository navigation
Conversation
Electron 系应用(Chrome、VS Code 类)的周围文本上报是异步滞后的:上屏一个词 以后,下一次按键报来的还是上屏之前的光标前的字。数字后面打词再打句号, 旧上报里的数字把句号定成了半角(1:1复刻.)。 带 SURROUNDING 的 prev_char 和会话自己记的上一个字对不上时当作不知道 (同 Gloridust#260 修退格滞后的思路);真是用户挪了光标,下一拍上报和记忆对上了 就自动恢复。按键级实测:上屏 0.7 秒后应用仍报着上屏前的 '1'。
Gloridust
added a commit
that referenced
this pull request
Nov 22, 2026
空的输入框里上屏、应用又把它清空了(聊天框点了发送)时,报来的也和上屏前一模一样(都是光标前没有字), 被当成了应用没跟上,上文没作废:macOS、Windows 外壳的「清空输入框后不学上一次上屏的字的搭配」因此失败。 只在报来的光标前有字时才认。
Owner
|
谢谢按键级的取证,问题定位得很准:会话明明记得刚上屏了什么,却被慢了的上报盖掉。这个修复已经进了 判断条件改了一下。原来是「报来的和会话记的对不上就当不知道」,但光标真的挪了(鼠标点到别处、在应用里删了字)也会对不上, 现在只认应用没跟上的那一种:
你那个场景( 这个 PR 是开到 |
lanshi17
pushed a commit
to lanshi17/WowType
that referenced
this pull request
Nov 23, 2026
Gloridust#295 的判断是「报来的和会话记的对不上就当不知道」,光标真的挪了也会对不上: 上文核对(context_is_checked_against_surrounding_text)、自动配对核对两边 (auto_pair_checks_char_after_cursor)两条测试因此失败。 改成只认应用没跟上的那一种:会话上屏那一下外壳报的光标前的字记下来,之后的键报来的 还和它一模一样、又和会话自己记的上一个字不一样,才是慢了,用会话自己记的(不是当不知道: 自动空格、上文核对照常)。报来的变了、按了交给应用的方向键 / 退格 / 回车、reset 以后都照常信应用的。 鼠标点候选上屏的也算。慢好几拍、打字途中一直慢着的也接得上。 测试:1:1你好。、连着的逗号、上屏后接着打数字再打点、光标真的挪了、方向键、reset、上文、鼠标点选。
Gloridust
added a commit
that referenced
this pull request
Nov 23, 2026
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.
现象
在 Electron 系应用(Chrome / VS Code 类)里,数字后面打词再打句号,句号被定成半角:
「删掉重打」正常(#260 修的那个路径),但第一次打必现。
根因(按键级取证)
给外壳的
sessionKey加了一行日志,实机抓到的完整序列(打1 : 1 fuke␣ .):Electron 的周围文本是异步上报的,滞后好几拍。会话这边只要带 SURROUNDING 就盲信
prev_char,自己明明记得刚上屏了「复刻」(last_char=刻),却被滞后的旧值覆盖,句号撞上数字规则成了半角。核心层、数字规则本身都没错,错在信任策略。
修法
沿用 #260 修退格滞后的思路:带 SURROUNDING 的
prev_char和会话自己记的上一个字对不上时,当作不知道(
prev_char=None、去掉 SURROUNDING 位、last_char=None),标点按全角走。真是用户挪了光标,下一拍上报和记忆对上了就自动恢复——最坏情况
错一个标点的全半角,比一直半角好。
测试
punct_not_halved_by_lagging_surrounding三个场景:全套 360 个测试通过;本机(Arch + niri + Electron 应用)实测
1:1复刻。恢复正常。