From 5bcd0561968ecf1409670c546b78131e71a9c310 Mon Sep 17 00:00:00 2001 From: Sergey Savenko Date: Wed, 9 Sep 2015 22:49:31 +0300 Subject: [PATCH] Do not show intention bulb when a fix range collapses (IDEA-114727) --- .../codeInsight/daemon/impl/ShowIntentionsPass.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java index 2c9c85c6479e..dde704820509 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java @@ -44,6 +44,7 @@ import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.Segment; import com.intellij.psi.IntentionFilterOwner; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; @@ -94,19 +95,19 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass { @NotNull List outList, int group, int offset) { - if (info.quickFixActionMarkers == null) return; + if (info.quickFixActionMarkers == null || info.getFixTextRange().isEmpty()) return; if (group != -1 && group != info.getGroup()) return; Editor injectedEditor = null; PsiFile injectedFile = null; for (Pair pair : info.quickFixActionMarkers) { HighlightInfo.IntentionActionDescriptor actionInGroup = pair.first; RangeMarker range = pair.second; - if (!range.isValid()) continue; + if (!range.isValid() || isEmpty(range)) continue; if (DumbService.isDumb(file.getProject()) && !DumbService.isDumbAware(actionInGroup.getAction())) { continue; } - + int start = range.getStartOffset(); int end = range.getEndOffset(); final Project project = file.getProject(); @@ -133,6 +134,10 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass { } } + private static boolean isEmpty(@NotNull Segment segment) { + return segment.getEndOffset() <= segment.getStartOffset(); + } + public static class IntentionsInfo { public final List intentionsToShow = ContainerUtil.createLockFreeCopyOnWriteList(); public final List errorFixesToShow = ContainerUtil.createLockFreeCopyOnWriteList();