fix(SquirrelInputController): boundary check to prevent crash#1044
fix(SquirrelInputController): boundary check to prevent crash#1044LEOYoon-Tsaw merged 3 commits intorime:masterfrom
Conversation
|
关于 #1045 : 此前的代码中: 和我之前的commit: https://github.com/ecstasoy/squirrel/blob/b20aea24f843899fff5bc83372cacffddd818573/sources/SquirrelInputController.swift#L472 这里会出问题: 修改后:
此时符号能正常作为candidate和preedit同时出现并且不会崩溃 |
b20aea2 to
d66e20b
Compare
- make sure candidatePreview is trimmed only when it is legal - add clamped() util function to clamp out-of-bounds values - prevent index out-of-bounds when candidatePreview is empty
a751bb2 to
58f42e6
Compare
|
觀察輸入,原先的算法似乎不會導致越界錯誤。 我重現了崩潰,但崩潰的不是鼠鬚管,而是 Chrome。 這個 PR 的改法是讓鼠鬚管無法發出導致錯誤的消息,從而規避問題。 |
This case seems to be a bug. I'll keep looking into it. |
这个确信是另一个问题,当inline_preedit和inline_candidate都是true的时候show()中的caretPos计算会产生负数,我之前说clamped可能还有用处就是这里,您可以再看看。 |
|
之前的測試方法不對, patch:
style/inline_preedit: false
style/inline_candidate: true可以重現崩潰。 |
|
不如擇期重新實現吧。 我沒想到 LEO 老師會做這麼複雜的功能,如果給 librime 多加接口,做起來應該會容易些。 |
我想的是任何開關都可以任意組合,確實由librime來實現會好得多,前端就做展示,不做複雜邏輯 |
|
崩溃的问题还是要尽快解决的 |
|
Let's focus on the bug #1041 itself, don't make other changes. |
R²ime ? |
一開始只是順手把這個組合實現了,沒想到還有不少人真的用,那確實可以mark一下,雖然不知道R²ime排期到哪年了😂 |


Make sure candidatePreview is trimmed only when it is legal
Fallback to empty string when pulling out the switcher with caption as preedit text
This seems to solve the problem mentioned in #1041