LayeredLexerEditorHighlighter: reset tokens on setText if a language has updated...
authorpeter <peter@jetbrains.com>
Thu, 2 Jun 2016 10:21:06 +0000 (12:21 +0200)
committerpeter <peter@jetbrains.com>
Thu, 2 Jun 2016 10:21:06 +0000 (12:21 +0200)
platform/editor-ui-ex/src/com/intellij/openapi/editor/ex/util/LayeredLexerEditorHighlighter.java
platform/editor-ui-ex/src/com/intellij/openapi/editor/ex/util/LexerEditorHighlighter.java

index 039dc7bd8e9d0e335f9d351dcc39224f1272eef7..1328c862c46ee6b5885bb5ab5dcb2b088b11cffa 100644 (file)
@@ -116,10 +116,11 @@ public class LayeredLexerEditorHighlighter extends LexerEditorHighlighter {
 
   @Override
   public void setText(@NotNull final CharSequence text) {
-    // do NOT synchronize before updateLayers due to deadlock with PsiLock
-    updateLayers();
-
-    super.setText(text);
+    if (updateLayers()) {
+      resetText(text);
+    } else {
+      super.setText(text);
+    }
   }
 
   @Override
@@ -181,8 +182,7 @@ public class LayeredLexerEditorHighlighter extends LexerEditorHighlighter {
       if (changed) {
         Document document = getDocument();
         if (document != null) {
-          myText = null;
-          super.setText(document.getImmutableCharSequence());
+          resetText(document.getImmutableCharSequence());
         }
       }
       return new LayeredHighlighterIteratorImpl(startOffset);
index baaf4c21183a05fa44a92aa3973dc04d83ab65b1..ca77e0c010eab29dc7c4e4ebadf1812a68ae56e0 100644 (file)
@@ -299,6 +299,11 @@ public class LexerEditorHighlighter implements EditorHighlighter, PrioritizedDoc
     return myEditor;
   }
 
+  protected final synchronized void resetText(@NotNull CharSequence text) {
+    myText = null;
+    doSetText(text);
+  }
+
   @Override
   public void setText(@NotNull CharSequence text) {
     synchronized (this) {