Recognizer input : insert ch in caret_pos
Pull request
Issue tracker
Fixes will automatically close the related issue
Fixes # caret_pos 不在字尾時 ab^cd key : 'z' input = abcdz <--- 錯誤 ab^cd key: 'z' input = abzcd < -- 修正
Feature
Describe feature of pull request
Unit test
- [ ] Done
Manual test
- [ ] Done
Code Review
- Unit and manual test pass
- GitHub Action CI pass
- At least one contributor reviews and votes
- Can be merged clean without conflicts
- PR will be merged by rebase upstream base
Additional Info
Question: does it work as expected after the fix?
After recognizer handled the pattern abzcd, the new inputabz^cd will probably not be given to matcher as abzcd but as abz, ending at cursor position.
Question: does it work as expected after the fix?
After
recognizerhandled the patternabzcd, the new inputabz^cdwill probably not be given tomatcherasabzcdbut asabz, ending at cursor position.
原來的 recoginzer ab^cdz 變更後 recognizer 使用 abc^dz recoginzer 收下後 ctx._input = abz^cd compisition.input = abz
- Compose() reset comp.input = abz https://github.com/rime/librime/blob/bcb3555d807f5601cbf0af85f98eb921921c2490/src/rime/engine.cc#L155-L157
-- matcher 使用 comp.input https://github.com/rime/librime/blob/bcb3555d807f5601cbf0af85f98eb921921c2490/src/rime/gear/matcher.cc#L26
這讓又產生一個疑問 recognizer patters 主要工作是確認 加入的 ch 是否在符合patterns 但是要比較 ctx._input 還是 ctx._input.substr(0, carte_pos) 才收下呢
從 Compose() 以後的 carte_pos 後的字串基本上是不管的
我有點兒腦霧。理不清楚。不要緊以後再看。 用來解決什麼實際問題,有具體的例子嗎。
一般正常輸入時 的確是 在 context.input 後面加上 字元,比較pattern 可是 當 caret_pos(^: caret_pos) 在 字串中間時 , active_input += ch 比較pattern 有點怪 abc^def 輸入z 應該 是 abcz^def 而不是 abc^defz