appendToHistoryDocument(history, myPrompt);
}
final int localStartOffset = textRange.getStartOffset();
String text;
EditorHighlighter highlighter;
if (consoleEditor instanceof EditorWindow) {
EditorWindow editorWindow = (EditorWindow) consoleEditor;
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
PsiFile file = editorWindow.getInjectedFile();
final VirtualFile virtualFile = file.getVirtualFile();
assert virtualFile != null;
highlighter = HighlighterFactory.createHighlighter(virtualFile, scheme, getProject());
String fullText = InjectedLanguageUtil.getUnescapedText(file, null, null);
highlighter.setText(fullText);
text = textRange.substring(fullText);
} else {
text = consoleEditor.getDocument().getText(textRange);
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();
final HighlighterIterator iterator = highlighter.createIterator(localStartOffset);
final int localEndOffset = textRange.getEndOffset();
while (!iterator.atEnd()) {
final int itStart = iterator.getStart();
if (itStart > localEndOffset) break;
final int itEnd = iterator.getEnd();