From 55425187bd64379b401428f1b023a5ea64d66e51 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 12 Aug 2008 21:03:24 +0400 Subject: [PATCH] weird highlighting fix --- .../codeInsight/daemon/impl/LocalInspectionsPass.java | 6 +++--- .../com/intellij/injected/editor/DocumentWindowImpl.java | 14 +++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java index 28e0ce7da2..b5f4df8853 100644 --- a/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java +++ b/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java @@ -337,9 +337,9 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass HighlightInfoType level = highlightTypeFromDescriptor(descriptor, severity); HighlightInfo info = createHighlightInfo(descriptor, tool, level,emptyActionRegistered); if (info == null) continue; - TextRange editable = documentRange.intersectWithEditable(new TextRange(info.startOffset, info.endOffset)); - if (editable == null) continue; - TextRange hostRange = documentRange.injectedToHost(editable); + //TextRange editable = documentRange.intersectWithEditable(new TextRange(info.startOffset, info.endOffset)); + //if (editable == null) continue; + TextRange hostRange = documentRange.injectedToHost(new TextRange(info.startOffset, info.endOffset)); HighlightInfo patched = HighlightInfo.createHighlightInfo(info.type, psiElement, hostRange.getStartOffset(), hostRange.getEndOffset(), info.description, info.toolTip); if (patched != null) { registerQuickFixes(tool, descriptor, patched,emptyActionRegistered); diff --git a/lang-impl/src/com/intellij/injected/editor/DocumentWindowImpl.java b/lang-impl/src/com/intellij/injected/editor/DocumentWindowImpl.java index 1a8b442e58..aae18c72e0 100644 --- a/lang-impl/src/com/intellij/injected/editor/DocumentWindowImpl.java +++ b/lang-impl/src/com/intellij/injected/editor/DocumentWindowImpl.java @@ -385,26 +385,30 @@ public class DocumentWindowImpl extends UserDataHolderBase implements Disposable return injectedToHost(offset, true); } - private int injectedToHost(int offset, boolean strict) { + private int injectedToHost(int offset, boolean glueLeft) { if (offset < myPrefixes[0].length()) return myRelevantRangesInHostDocument[0].getStartOffset(); + int prevEnd = 0; for (int i = 0; i < myRelevantRangesInHostDocument.length; i++) { RangeMarker currentRange = myRelevantRangesInHostDocument[i]; offset -= myPrefixes[i].length(); int length = currentRange.getEndOffset() - currentRange.getStartOffset(); - if (offset < length || !strict && offset == length) { + if (offset < 0) { + return glueLeft? prevEnd : currentRange.getStartOffset() - 1; + } + else if (offset < length || offset == length && !glueLeft) { return currentRange.getStartOffset() + offset; } offset -= length; offset -= mySuffixes[i].length(); + prevEnd = currentRange.getEndOffset(); } return myRelevantRangesInHostDocument[myRelevantRangesInHostDocument.length-1].getEndOffset(); } @NotNull public TextRange injectedToHost(@NotNull TextRange injected) { - final int start = injectedToHost(injected.getStartOffset()); - final int endProbe = injectedToHost(injected.getEndOffset(), false); - final int end = start > endProbe? injectedToHost(injected.getEndOffset()) : endProbe; + final int start = injectedToHost(injected.getStartOffset(), true); + final int end = injectedToHost(injected.getEndOffset(), false); return new ProperTextRange(start, end); } -- 2.11.4.GIT