speed up gutter painting

This commit is contained in:
Dmitry Batrak
2014-10-23 15:44:40 +04:00
parent 9e854ecde1
commit f2c5610b77
@@ -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<RangeMarker> 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;