From 1449cb56f4d3e90857b776950853f6f04a9ce99f Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 3 Feb 2012 14:23:43 +0400 Subject: [PATCH] IDEA-80533 --- .../intellij/codeInsight/CodeInsightTestCase.java | 12 ++++++++++++ .../daemon/impl/UpdateHighlightersUtil.java | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java index 370d28d5d44b..bc53dcfd41df 100644 --- a/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/CodeInsightTestCase.java @@ -722,4 +722,16 @@ public abstract class CodeInsightTestCase extends PsiTestCase { assertNotNull("Package " + name + " not found", aPackage); return aPackage; } + + protected void delete(@NotNull final Editor editor) { + CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() { + @Override + public void run() { + EditorActionManager actionManager = EditorActionManager.getInstance(); + EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_DELETE); + + actionHandler.execute(editor, DataManager.getInstance().getDataContext()); + } + }, "delete", editor.getDocument()); + } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java index 73828acb0a78..8f5a44c6962a 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java @@ -253,7 +253,7 @@ public class UpdateHighlightersUtil { RangeHighlighter highlighter = info.highlighter; int hiStart = highlighter.getStartOffset(); int hiEnd = highlighter.getEndOffset(); - if (!info.fromInjection && (hiEnd <= startOffset || hiStart>=endOffset)) return true; // injections are oblivious to restricting range + if (!info.fromInjection && hiEnd < document.getTextLength() && (hiEnd <= startOffset || hiStart>=endOffset)) return true; // injections are oblivious to restricting range boolean toRemove = !(hiEnd == document.getTextLength() && range.getEndOffset() == document.getTextLength()) && !range.containsRange(hiStart, hiEnd) ; @@ -277,7 +277,7 @@ public class UpdateHighlightersUtil { @Override public boolean process(int offset, HighlightInfo info, boolean atStart, Collection overlappingIntervals) { if (!atStart) return true; - if (!info.fromInjection && (info.getEndOffset() <= startOffset || info.getStartOffset()>=endOffset)) return true; // injections are oblivious to restricting range + if (!info.fromInjection && info.getEndOffset() < document.getTextLength() && (info.getEndOffset() <= startOffset || info.getStartOffset()>=endOffset)) return true; // injections are oblivious to restricting range if (info.isFileLevelAnnotation && psiFile != null && psiFile.getViewProvider().isPhysical()) { addFileLevelHighlight(project, group, info, psiFile);