[ide-console] Add folding to history commands
This commit is contained in:
committed by
Pavel V. Talanov
parent
48866fbeeb
commit
6d8c6857b8
@@ -45,6 +45,7 @@ public class KotlinHistoryHighlighter(private val runner: KotlinConsoleRunner )
|
||||
consoleView.flushDeferredText()
|
||||
EditorUtil.scrollToTheEnd(historyEditor)
|
||||
consoleDocument.setText("")
|
||||
addFoldingRegion(historyEditor, startOffset, endOffset, trimmedCommandText)
|
||||
|
||||
historyEditor.markupModel let {
|
||||
it.addRangeHighlighter(startOffset, endOffset, HighlighterLayer.LAST, null, HighlighterTargetArea.EXACT_RANGE)
|
||||
@@ -70,4 +71,15 @@ public class KotlinHistoryHighlighter(private val runner: KotlinConsoleRunner )
|
||||
historyDocument.insertString(textLength, "\n")
|
||||
}
|
||||
}
|
||||
|
||||
private fun addFoldingRegion(historyEditor: EditorEx, startOffset: Int, endOffset: Int, command: String) {
|
||||
val cmdLines = command.lines()
|
||||
val linesCount = cmdLines.size()
|
||||
if (linesCount < 2) return
|
||||
|
||||
val foldingModel = historyEditor.foldingModel
|
||||
foldingModel.runBatchFoldingOperation {
|
||||
foldingModel.addFoldRegion(startOffset, endOffset, "${cmdLines[0]} ...")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user