Skip to content

Commit

Permalink
Autocomplete: account for halfway processed composing characters.
Browse files Browse the repository at this point in the history
Languages that rely on composing characters occasionally include halfway
composed characters in the user input length.

(cherry picked from commit 59eafc5)

Change-Id: Ie5bf92050bfa4c39bc7e7be9b23b763d2b7fb51e
Fixed: 1317406
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4133715
Reviewed-by: Gang Wu <gangwu@chromium.org>
Commit-Queue: Gang Wu <gangwu@chromium.org>
Auto-Submit: Tomasz Wiszkowski <ender@google.com>
Cr-Original-Commit-Position: refs/heads/main@{#1088404}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4162955
Commit-Queue: Tomasz Wiszkowski <ender@google.com>
Cr-Commit-Position: refs/branch-heads/5481@{#238}
Cr-Branched-From: 130f3e4-refs/heads/main@{#1084008}
  • Loading branch information
tomasz-wiszkowski authored and Chromium LUCI CQ committed Jan 12, 2023
1 parent 752ad43 commit d131664
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,15 @@ public boolean onBeginImeCommand() {
if (mBatchEditNestCount == 1) {
mPreBatchEditState.copyFrom(mCurrentState);
} else if (mDeletePostfixOnNextBeginImeCommand > 0) {
// Note: in languages that rely on character composition, the last incomplete
// character may not be recognized as part of the string, but it may still be
// accounted for by the mDeletePostfixOnNextBeginImeCommand.
// In such case, the text below is actually shorter than the user input, and the
// computed string boundaries enter negative index space.
int len = mDelegate.getText().length();
if (mDeletePostfixOnNextBeginImeCommand > len) {
mDeletePostfixOnNextBeginImeCommand = len;
}
mDelegate.getText().delete(len - mDeletePostfixOnNextBeginImeCommand, len);
}
mDeletePostfixOnNextBeginImeCommand = 0;
Expand Down

0 comments on commit d131664

Please sign in to comment.