Skip to content
This repository was archived by the owner on Aug 10, 2022. It is now read-only.

Commit 100abcb

Browse files
committed
Fix bobbylight#204: Custom TokenMaker hangs with overridden isIdentifierChar()
1 parent 69f2823 commit 100abcb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/org/fife/ui/rsyntaxtextarea/RSyntaxTextAreaEditorKit.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.awt.Font;
1313
import java.awt.Point;
1414
import java.awt.event.ActionEvent;
15+
import java.text.CharacterIterator;
1516
import java.util.ResourceBundle;
1617
import java.util.Stack;
1718

@@ -232,7 +233,7 @@ protected int getWordStart(RTextArea textArea, int offs)
232233
}
233234
do {
234235
ch = seg.previous();
235-
} while (doc.isIdentifierChar(languageIndex, ch));
236+
} while (doc.isIdentifierChar(languageIndex, ch) && ch != CharacterIterator.DONE);
236237
}
237238

238239
// The "word" is whitespace
@@ -1143,7 +1144,8 @@ protected int getWordEnd(RTextArea textArea, int offs)
11431144
if (doc.isIdentifierChar(languageIndex, ch)) {
11441145
do {
11451146
ch = seg.next();
1146-
} while (doc.isIdentifierChar(languageIndex, ch));
1147+
} while (doc.isIdentifierChar(languageIndex, ch) &&
1148+
ch != CharacterIterator.DONE);
11471149
}
11481150

11491151
// The "word" is whitespace.
@@ -1745,7 +1747,8 @@ protected int getNextWord(RTextArea textArea, int offs)
17451747
if (doc.isIdentifierChar(languageIndex, ch)) {
17461748
do {
17471749
ch = seg.next();
1748-
} while (doc.isIdentifierChar(languageIndex, ch));
1750+
} while (doc.isIdentifierChar(languageIndex, ch) &&
1751+
ch != CharacterIterator.DONE);
17491752
}
17501753

17511754
// Skip groups of "anything else" (operators, etc.).
@@ -1919,7 +1922,8 @@ protected int getPreviousWord(RTextArea textArea, int offs)
19191922
if (doc.isIdentifierChar(languageIndex, ch)) {
19201923
do {
19211924
ch = seg.previous();
1922-
} while (doc.isIdentifierChar(languageIndex, ch));
1925+
} while (doc.isIdentifierChar(languageIndex, ch) &&
1926+
ch != CharacterIterator.DONE);
19231927
}
19241928

19251929
// Skip groups of "anything else" (operators, etc.).

0 commit comments

Comments
 (0)