Skip to content

Commit

Permalink
Merge pull request tranleduy2000#71 from axkr/master
Browse files Browse the repository at this point in the history
Improve AutoCompleteFunctionEditText
  • Loading branch information
tranleduy2000 authored Jul 6, 2019
2 parents 8b6b8e3 + ce913b7 commit 127c7d0
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,11 @@ public void highlight(Editable editable) {
}

public class FunctionTokenizer implements Tokenizer {
String token = "!@#$%^&*()_+-={}|[]:'<>/<.?1234567890";

@Override
public int findTokenStart(CharSequence text, int cursor) {
int i = cursor;
while (i > 0 && !token.contains(Character.toString(text.charAt(i - 1)))) {
while (i > 0 && Character.isJavaIdentifierStart(text.charAt(i - 1))) {
i--;
}
while (i < cursor && text.charAt(i) == ' ') {
Expand All @@ -169,7 +168,7 @@ public int findTokenEnd(CharSequence text, int cursor) {
int len = text.length();

while (i < len) {
if (token.contains(Character.toString(text.charAt(i - 1)))) {
if (!Character.isJavaIdentifierStart(text.charAt(i - 1))) {
return i;
} else {
i++;
Expand All @@ -187,7 +186,7 @@ public CharSequence terminateToken(CharSequence text) {
i--;
}

if (i > 0 && token.contains(Character.toString(text.charAt(i - 1)))) {
if (i > 0 && Character.isJavaIdentifierStart(text.charAt(i - 1))) {
return text;
} else {
if (text instanceof Spanned) {
Expand Down

0 comments on commit 127c7d0

Please sign in to comment.