mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-68357 IDEA unresponsive with large MXML files
Don't using highlighter iterator for determining target markup model range to process on typing. Reason: the highlighter doesn't know about injected context, hence, its lexer-based iterator considers all injected code as a single big token (CDATA in our case). Subsequent markup model processing for such a large range causes unnecessary CPU consuming. That is the reason why we use actual document change-based region and process only highlighters that overlap with it.
This commit is contained in:
+4
-13
@@ -28,10 +28,8 @@ import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.editor.ex.DocumentEx;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.ex.MarkupModelEx;
|
||||
import com.intellij.openapi.editor.ex.RangeHighlighterEx;
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.openapi.editor.impl.RangeMarkerTree;
|
||||
import com.intellij.openapi.editor.impl.RedBlackTree;
|
||||
import com.intellij.openapi.editor.markup.*;
|
||||
@@ -591,18 +589,11 @@ public class UpdateHighlightersUtil {
|
||||
final MarkupModel markup = document.getMarkupModel(project);
|
||||
assertMarkupConsistent(markup, project);
|
||||
|
||||
int offset = e.getOffset();
|
||||
Editor[] editors = EditorFactory.getInstance().getEditors(document, project);
|
||||
if (editors.length == 0) return;
|
||||
Editor editor = editors[0]; // use any editor - just to fetch SelectInEditorManager
|
||||
HighlighterIterator iterator = ((EditorEx)editor).getHighlighter().createIterator(Math.max(0, offset - 1));
|
||||
if (iterator.atEnd()) return;
|
||||
final int start = iterator.getStart();
|
||||
while (iterator.getEnd() < e.getOffset() + Math.max(e.getOldLength(), e.getNewLength())) {
|
||||
iterator.advance();
|
||||
if (iterator.atEnd()) return;
|
||||
}
|
||||
final int end = iterator.getEnd();
|
||||
if (editors.length <= 0) return;
|
||||
|
||||
final int start = e.getOffset();
|
||||
final int end = start + Math.max(e.getOldLength(), e.getNewLength());
|
||||
|
||||
final boolean[] highlightersChanged = {false};
|
||||
final List<HighlightInfo> removed = new ArrayList<HighlightInfo>();
|
||||
|
||||
Reference in New Issue
Block a user