diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/IterationState.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/IterationState.java index 1c88507fbe5a..2d1ded2c9a36 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/IterationState.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/IterationState.java @@ -83,6 +83,7 @@ public final class IterationState { private final TextAttributes myMergedAttributes = new TextAttributes(); + @Nullable private final HighlighterIterator myHighlighterIterator; private final HighlighterSweep myView; private final HighlighterSweep myDoc; @@ -118,6 +119,7 @@ public final class IterationState { private final DocumentEx myDocument; private final EditorEx myEditor; private final Color myReadOnlyColor; + private final boolean myUseOnlyFullLineHighlighters; public IterationState(@NotNull EditorEx editor, int start, int end, boolean useCaretAndSelection) { this(editor, start, end, useCaretAndSelection, false); @@ -130,9 +132,10 @@ public final class IterationState { myEnd = end; myEditor = editor; + myUseOnlyFullLineHighlighters = useOnlyFullLineHighlighters; LOG.assertTrue(myStartOffset <= myEnd); - myHighlighterIterator = editor.getHighlighter().createIterator(start); + myHighlighterIterator = useOnlyFullLineHighlighters ? null : editor.getHighlighter().createIterator(start); boolean hasSelection = useCaretAndSelection && (editor.getCaretModel().supportsMultipleCarets() || editor.getSelectionModel().hasSelection() || editor.getSelectionModel().hasBlockSelection()); if (!hasSelection) { @@ -265,7 +268,9 @@ public final class IterationState { advanceCurrentSelectionIndex(); advanceCurrentVirtualSelectionIndex(); - myCurrentFold = myFoldingModel.fetchOutermost(myStartOffset); + if (!myUseOnlyFullLineHighlighters) { + myCurrentFold = myFoldingModel.fetchOutermost(myStartOffset); + } if (myCurrentFold != null) { myEndOffset = myCurrentFold.getEndOffset(); } @@ -281,6 +286,9 @@ public final class IterationState { } private int getHighlighterEnd(int start) { + if (myHighlighterIterator == null) { + return myEnd; + } while (!myHighlighterIterator.atEnd()) { int end = myHighlighterIterator.getEnd(); if (end > start) { @@ -304,6 +312,9 @@ public final class IterationState { } private int getGuardedBlockEnd(int start) { + if (myUseOnlyFullLineHighlighters) { + return myEnd; + } List blocks = myDocument.getGuardedBlocks(); int min = myEnd; //noinspection ForLoopReplaceableByForEach @@ -359,6 +370,9 @@ public final class IterationState { } private int getFoldRangesEnd(int startOffset) { + if (myUseOnlyFullLineHighlighters) { + return myEnd; + } int end = myEnd; FoldRegion[] topLevelCollapsed = myFoldingModel.fetchTopLevel(); if (topLevelCollapsed != null) { @@ -401,15 +415,15 @@ public final class IterationState { } private void reinit() { - if (myHighlighterIterator.atEnd()) { + if (myHighlighterIterator != null && myHighlighterIterator.atEnd()) { return; } boolean isInSelection = isInSelection(); boolean isInCaretRow = myStartOffset >= myCaretRowStart && myStartOffset < myCaretRowEnd; - boolean isInGuardedBlock = myDocument.getOffsetGuard(myStartOffset) != null; + boolean isInGuardedBlock = !myUseOnlyFullLineHighlighters && myDocument.getOffsetGuard(myStartOffset) != null; - TextAttributes syntax = myHighlighterIterator.getTextAttributes(); + TextAttributes syntax = myHighlighterIterator == null ? null : myHighlighterIterator.getTextAttributes(); TextAttributes selection = isInSelection ? mySelectionAttributes : null; TextAttributes caret = isInCaretRow ? myCaretRowAttributes : null;