Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognizer input : insert ch in caret_pos #692

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shewer
Copy link
Contributor

@shewer shewer commented Aug 15, 2023

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

  1. Unit and manual test pass
  2. GitHub Action CI pass
  3. At least one contributor reviews and votes
  4. Can be merged clean without conflicts
  5. PR will be merged by rebase upstream base

Additional Info

Copy link
Member

@lotem lotem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. LGTM

@lotem
Copy link
Member

lotem commented Oct 15, 2023

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.

@shewer
Copy link
Contributor Author

shewer commented Oct 15, 2023

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.

原來的 recoginzer ab^cdz
變更後 recognizer 使用 abc^dz
recoginzer 收下後
ctx._input = abz^cd
compisition.input = abz

  • Compose() reset comp.input = abz

    librime/src/rime/engine.cc

    Lines 155 to 157 in bcb3555

    const string active_input = ctx->input().substr(0, ctx->caret_pos());
    DLOG(INFO) << "active input: " << active_input;
    comp.Reset(active_input);

-- matcher 使用 comp.input

auto match = patterns_.GetMatch(segmentation->input(), *segmentation);

這讓又產生一個疑問 recognizer patters 主要工作是確認
加入的 ch 是否在符合patterns 但是要比較 ctx._input 還是 ctx._input.substr(0, carte_pos) 才收下呢

從 Compose() 以後的 carte_pos 後的字串基本上是不管的

@lotem
Copy link
Member

lotem commented Feb 9, 2024

我有點兒腦霧。理不清楚。不要緊以後再看。
用來解決什麼實際問題,有具體的例子嗎。

@shewer
Copy link
Contributor Author

shewer commented Feb 9, 2024

一般正常輸入時 的確是 在 context.input 後面加上 字元,比較pattern
可是 當 caret_pos(^: caret_pos) 在 字串中間時 , active_input += ch 比較pattern 有點怪
abc^def 輸入z 應該 是 abcz^def 而不是 abc^defz

@eagleoflqj eagleoflqj requested a review from lotem June 18, 2024 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants