rime / librime

Rime Input Method Engine, the core library
https://rime.im
BSD 3-Clause "New" or "Revised" License
3.36k stars 550 forks source link

delete candidate APIs ignore index #899

Closed eagleoflqj closed 3 months ago

eagleoflqj commented 3 months ago

Describe the bug

delete_candidate and delete_candidate_on_current_page ignore index and always delete highlighted candidate.

To Reproduce

  1. In luna-pinyin, commit 2 words with the same pinyin and not in dict.
  2. Right click the 2nd one on f5m or long press the 2nd one on f5a.
  3. Forget word.
  4. The 1st word is gone.

Expected behavior

The 2nd word is gone.

Log

I20240619 12:02:23.835766 0x170437000 context.cc:152] Deleting candidate: '苫次
I20240619 12:02:23.835961 0x170437000 memory.cc:127] deleting entry: '善此'.
I20240619 12:02:23.836090 0x170437000 level_db.cc:182] update db entry: shan ci 善此 => c=-1 d=0.99005 t=3

Flavor(please complete the following information):

Additional context

Candidate info is clearly lost: https://github.com/rime/librime/blob/a4f24fd705e78ccaf7d1fa65f36c31341ecab180/src/rime/context.cc#L151-L154

Always delete selected: https://github.com/rime/librime/blob/a4f24fd705e78ccaf7d1fa65f36c31341ecab180/src/rime/gear/memory.cc#L123-L124