IDEA-186750 Indent guides often disappear

This commit is contained in:
Dmitry Batrak
2018-05-31 19:22:46 +03:00
parent f171a16b52
commit 17ff674fa8
@@ -1,6 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
/*
* @author max
@@ -45,10 +43,8 @@ import com.intellij.util.text.CharArrayUtil;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.*;
import java.util.List;
import java.util.Map;
public class IndentsPass extends TextEditorHighlightingPass implements DumbAware {
private static final Key<List<RangeHighlighter>> INDENT_HIGHLIGHTERS_IN_EDITOR_KEY = Key.create("INDENT_HIGHLIGHTERS_IN_EDITOR_KEY");
@@ -228,10 +224,14 @@ public class IndentsPass extends TextEditorHighlightingPass implements DumbAware
int curRange = 0;
if (oldHighlighters != null) {
// after document change some range highlighters could have become invalid, or the order could have been broken
oldHighlighters.sort(Comparator.comparing((RangeHighlighter h) -> !h.isValid())
.thenComparing(Segment.BY_START_OFFSET_THEN_END_OFFSET));
int curHighlight = 0;
while (curRange < myRanges.size() && curHighlight < oldHighlighters.size()) {
TextRange range = myRanges.get(curRange);
RangeHighlighter highlighter = oldHighlighters.get(curHighlight);
if (!highlighter.isValid()) break;
int cmp = compare(range, highlighter);
if (cmp < 0) {
@@ -251,6 +251,7 @@ public class IndentsPass extends TextEditorHighlightingPass implements DumbAware
for (; curHighlight < oldHighlighters.size(); curHighlight++) {
RangeHighlighter highlighter = oldHighlighters.get(curHighlight);
if (!highlighter.isValid()) break;
highlighter.dispose();
}
}