Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 07a11f49 authored by Gilles Debunne's avatar Gilles Debunne
Browse files

Selecting text from a punctuation sign selects previous word.

Cherry picked from a revert in https://android-git.corp.google.com/g/#change,82252

Change-Id: I141bbff2a0f9a8ab40f10c59fc1280b94b38e4b6
parent 3578e153
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -7598,6 +7598,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        int start = end;

        for (; start > 0; start--) {
            if (start == end) {
                // Cases where the text ends with a '.' and we select from the end of the line
                // (right after the dot), or when we select from the space character in "aaa, bbb".
                final char c = mTransformed.charAt(start);
                final int type = Character.getType(c);
                if (type == Character.OTHER_PUNCTUATION) continue;
            }
            if (!isWordCharacter(start - 1)) break;
            if ((end - start) > MAX_LENGTH) return -1;
        }