@@ -125,7 +125,7 @@ public EditorPanel(Gui gui) {
125125 customizeEditor (this .editor );
126126 this .editor .addCaretListener (event -> onCaretMove (event .getDot (), this .mouseIsPressed ));
127127
128- // Remove tabulator from focus traversal keys (we give it a different meaning)
128+ // Remove the tab key from focus traversal keys (we give it a different meaning)
129129 Set <AWTKeyStroke > focusTraversalKeys = new HashSet <>(this .editor .getFocusTraversalKeys (KeyboardFocusManager .FORWARD_TRAVERSAL_KEYS ));
130130 focusTraversalKeys .removeIf (key -> key .getKeyCode () == KeyEvent .VK_TAB );
131131 this .editor .setFocusTraversalKeys (KeyboardFocusManager .FORWARD_TRAVERSAL_KEYS , focusTraversalKeys );
@@ -681,28 +681,34 @@ private void showReference0(EntryReference<Entry<?>, Entry<?>> reference) {
681681 }
682682 }
683683
684+ /**
685+ * Navigate to the next obfuscated token that can be renamed.
686+ *
687+ * <p>If the tokens are damaged, then this method should not be called
688+ * synchronously. Instead, the call should be wrapped in a
689+ * {@link SwingUtilities#invokeLater(Runnable)}. Failing to do so
690+ * will induce invalid token highlighting regions.
691+ */
684692 public void navigateToNextObfuscatedToken () {
685- SwingUtilities .invokeLater (() -> {
686- int caretPos = this .getEditor ().getCaretPosition ();
687- Token token = this .getToken (this .getEditor ().getCaretPosition ());
688- NavigableSet <Token > obfuscatedTokens = this .getSource ().getTokenStore ().getByType ().get (RenamableTokenType .OBFUSCATED );
689- Token next ;
690-
691- if (token == null ) {
692- next = obfuscatedTokens .higher (new Token (caretPos , caretPos , null ));
693- } else {
694- next = obfuscatedTokens .higher (token );
695- }
693+ int caretPos = this .getEditor ().getCaretPosition ();
694+ Token token = this .getToken (this .getEditor ().getCaretPosition ());
695+ NavigableSet <Token > obfuscatedTokens = this .getSource ().getTokenStore ().getByType ().get (RenamableTokenType .OBFUSCATED );
696+ Token next ;
696697
697- if (next == null ) {
698- // Wrap to start of document
699- next = obfuscatedTokens .pollFirst ();
700- }
698+ if (token == null ) {
699+ next = obfuscatedTokens .higher (new Token (caretPos , caretPos , null ));
700+ } else {
701+ next = obfuscatedTokens .higher (token );
702+ }
701703
702- if (next != null ) {
703- this .navigateToToken (next );
704- }
705- });
704+ if (next == null ) {
705+ // Wrap to start of document
706+ next = obfuscatedTokens .pollFirst ();
707+ }
708+
709+ if (next != null ) {
710+ this .navigateToToken (next );
711+ }
706712 }
707713
708714 public void navigateToToken (Token token ) {
0 commit comments