Skip to content

Commit

Permalink
fix: rollback of dc27449
Browse files Browse the repository at this point in the history
Sometimes `onUpdateSelection()` will be called before the cursor or
the candidate's length changed, causing `commitText` incorrectly.
  • Loading branch information
goofyz committed Dec 22, 2023
1 parent a3cf556 commit 1dfcefc
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions app/src/main/java/com/osfans/trime/ime/core/Trime.java
Original file line number Diff line number Diff line change
Expand Up @@ -701,20 +701,17 @@ public void onUpdateSelection(
super.onUpdateSelection(
oldSelStart, oldSelEnd, newSelStart, newSelEnd, candidatesStart, candidatesEnd);
if ((candidatesEnd != -1) && ((newSelStart != candidatesEnd) || (newSelEnd != candidatesEnd))) {
// 移動光標時,commit
getCurrentInputConnection().finishComposingText();
performEscape();
// 移動光標時,更新候選區
if ((newSelEnd < candidatesEnd) && (newSelEnd >= candidatesStart)) {
final int n = newSelEnd - candidatesStart;
Rime.setCaretPos(n);
updateComposing();
}
}
if ((candidatesStart == -1 && candidatesEnd == -1) && (newSelStart == 0 && newSelEnd == 0)) {
// 上屏後,清除候選區
performEscape();
}
if (candidatesEnd < newSelEnd || candidatesStart > newSelStart) {
// 點擊在"輸入文字"外,上屏
getCurrentInputConnection().finishComposingText();
performEscape();
}

// Update the caps-lock status for the current cursor position.
dispatchCapsStateToInputView();
}
Expand Down

0 comments on commit 1dfcefc

Please sign in to comment.