Skip to content

Conversation

@ecstasoy
Copy link
Contributor

Currently, candidatePreview can still be empty, which may lead to a crash when utf16Offset is called on it.
#1044 (comment)

This should close #1045

@ecstasoy ecstasoy changed the title fix(SquirrelInputController): no offset called on an empty string (#1045) fix(SquirrelInputController): no offset called on an empty string Jul 10, 2025
Copy link
Member

@LEOYoon-Tsaw LEOYoon-Tsaw left a comment

Choose a reason for hiding this comment

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

Looks good

@lotem
Copy link
Member

lotem commented Jul 12, 2025

可以先這樣改,但是治標不治本。

原因是 RimeApi::commit_text_preview 在通常的輸入過程中給出的是由「已選擇字詞」「當前候選詞」「未翻譯的輸入碼」拼接出的字符串,不完全符合 candidate_preview 的需要,因此 Squirrel 要從中截取。

截取字串所用的 start 等字段給出的是 preedit 中的位置,而不是 commit_text_preview 中的位置,有賴於 preedit 也包含「已選擇字詞」範圍爲 0..<start

而特殊狀態下,如移動光標至輸入碼的開始位置、方案選單等 phony 碼段,不再符合以上格式,仍按照這個算法截取就會出現問題。

這樣修可以控制住崩潰,但不知正常輸入的情況會不會受到影響?

@lotem lotem merged commit ab1db6c into rime:master Jul 12, 2025
1 check passed
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.

[Bug] 特定配置下中文模式输入数字和标点会导致崩溃

3 participants