REPL: fix IllegalArgumentException

Reproduce: select `Pause Output`
#EA-209571 Fixed
#EA-210364 Fixed
#KT-33329 Fixed
This commit is contained in:
Dmitry Gridin
2019-08-16 19:02:18 +07:00
parent f81fb40164
commit ef4bac1b46
2 changed files with 5 additions and 10 deletions
@@ -31,9 +31,10 @@ class HistoryUpdater(private val runner: KotlinConsoleRunner) {
val historyEditor = consoleView.historyViewer
addLineBreakIfNeeded(historyEditor)
val startOffset = historyEditor.document.textLength
val endOffset = startOffset + trimmedCommandText.length
addCommandTextToHistoryEditor(trimmedCommandText)
val endOffset = historyEditor.document.textLength
addFoldingRegion(historyEditor, startOffset, endOffset, trimmedCommandText)
historyEditor.markupModel.addRangeHighlighter(
@@ -46,19 +46,13 @@ class ReplOutputProcessor(
private val historyDocument = historyEditor.document
private val historyMarkup = historyEditor.markupModel
private fun textOffsets(text: String): Pair<Int, Int> {
consoleView.flushDeferredText() // flush before getting offsets to calculate them properly
val oldLen = historyDocument.textLength
val newLen = oldLen + text.length
return Pair(oldLen, newLen)
}
private fun printOutput(output: String, contentType: ConsoleViewContentType, iconWithTooltip: IconWithTooltip? = null) {
val (startOffset, endOffset) = textOffsets(output)
consoleView.flushDeferredText() // flush before getting offsets to calculate them properly
val startOffset = historyDocument.textLength
consoleView.print(output, contentType)
consoleView.flushDeferredText()
val endOffset = historyDocument.textLength
if (iconWithTooltip == null) return