From 2ba69f0c31228cda43ca9937029b4ad87cefee1d Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Wed, 20 Nov 2013 13:55:20 +0400 Subject: [PATCH] EA-45917 - IAE: RangeMarkerImpl. --- .../execution/console/LanguageConsoleImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java index d66de2d8abb0..5817e1ab10af 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java @@ -404,8 +404,7 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider { Document history = myHistoryViewer.getDocument(); MarkupModel markupModel = DocumentMarkupModel.forDocument(history, myProject, true); - int offset = history.getTextLength(); - appendToHistoryDocument(history, text); + int offset = appendToHistoryDocument(history, text); if (attributes == null) return; markupModel.addRangeHighlighter(offset, offset + text.length(), HighlighterLayer.SYNTAX, attributes, HighlighterTargetArea.EXACT_RANGE); } @@ -482,8 +481,7 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider { highlighter = consoleEditor.getHighlighter(); } //offset can be changed after text trimming after insert due to buffer constraints - appendToHistoryDocument(history, text); - int offset = history.getTextLength() - text.length(); + int offset = appendToHistoryDocument(history, text); final HighlighterIterator iterator = highlighter.createIterator(localStartOffset); final int localEndOffset = textRange.getEndOffset(); @@ -514,9 +512,11 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider { addTextToHistory(myPrompt, ConsoleViewContentType.USER_INPUT.getAttributes()); } - protected void appendToHistoryDocument(@NotNull Document history, @NotNull CharSequence text) { + // returns the real (cyclic-buffer-aware) start offset of the inserted text + protected int appendToHistoryDocument(@NotNull Document history, @NotNull CharSequence text) { ApplicationManager.getApplication().assertIsDispatchThread(); history.insertString(history.getTextLength(), text); + return history.getTextLength() - text.length(); } private static void duplicateHighlighters(@NotNull MarkupModel to, @NotNull MarkupModel from, int offset, @NotNull TextRange textRange) {