From 0d9d93fe2b2bdf0d348e36a8860f4dd98a8effb4 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Wed, 24 Dec 2014 19:02:42 +0300 Subject: [PATCH] IDEA-85298 When stopped at breakpoint, line should be highlighted in all panels containing that file - fixed hover color --- .../navigation/NavigationUtil.java | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/NavigationUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/NavigationUtil.java index 3617c944e888..e8774cedeeb8 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/NavigationUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/NavigationUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,11 @@ import com.intellij.navigation.GotoRelatedProvider; import com.intellij.navigation.NavigationItem; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.ex.MarkupModelEx; +import com.intellij.openapi.editor.ex.RangeHighlighterEx; +import com.intellij.openapi.editor.impl.DocumentMarkupModel; import com.intellij.openapi.editor.markup.HighlighterTargetArea; -import com.intellij.openapi.editor.markup.RangeHighlighter; +import com.intellij.openapi.editor.markup.MarkupModel; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileEditor.FileEditor; @@ -214,24 +217,26 @@ public final class NavigationUtil { */ @SuppressWarnings("UseJBColor") public static TextAttributes patchAttributesColor(TextAttributes attributes, @NotNull TextRange range, @NotNull Editor editor) { - int lineStart = editor.offsetToLogicalPosition(range.getStartOffset()).line; - int lineEnd = editor.offsetToLogicalPosition(range.getEndOffset()).line; - for (RangeHighlighter highlighter : editor.getMarkupModel().getAllHighlighters()) { - if (!highlighter.isValid()) continue; - if (highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE) { - int line = editor.offsetToLogicalPosition(highlighter.getStartOffset()).line; - if (line >= lineStart && line <= lineEnd) { - TextAttributes textAttributes = highlighter.getTextAttributes(); - if (textAttributes != null) { - Color color = textAttributes.getBackgroundColor(); - if (color != null && color.getBlue() > 128 && color.getRed() < 128 && color.getGreen() < 128) { - TextAttributes clone = attributes.clone(); - clone.setForegroundColor(Color.orange); - clone.setEffectColor(Color.orange); - return clone; - } - } - } + MarkupModel model = DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false); + if (model != null) { + if (!((MarkupModelEx)model).processRangeHighlightersOverlappingWith(range.getStartOffset(), range.getEndOffset(), + new Processor() { + @Override + public boolean process(RangeHighlighterEx highlighter) { + if (highlighter.isValid() && highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE) { + TextAttributes textAttributes = highlighter.getTextAttributes(); + if (textAttributes != null) { + Color color = textAttributes.getBackgroundColor(); + return !(color != null && color.getBlue() > 128 && color.getRed() < 128 && color.getGreen() < 128); + } + } + return true; + } + })) { + TextAttributes clone = attributes.clone(); + clone.setForegroundColor(Color.orange); + clone.setEffectColor(Color.orange); + return clone; } } return attributes;