[terminal] IJPL-213971 Fix exceptions caused by out-of-bounds offsets in TerminalBlocksDecorator

Always check that block start offset is in the model bounds.

GitOrigin-RevId: 4ed08212375b2fdb75c4c0e0ad9f5207c8240a4d
This commit is contained in:
Konstantin Hudyakov
2025-10-21 09:13:27 +00:00
committed by intellij-monorepo-bot
parent ee118062e5
commit f71b4cbc5a
@@ -93,7 +93,7 @@ internal class TerminalBlocksDecorator(
}
private fun createPromptDecoration(block: TerminalCommandBlock): BlockDecoration {
val startOffset = block.startOffset
val startOffset = block.startOffset.coerceAtLeast(outputModel.startOffset)
val endOffset = block.endOffset
val topInlay = createTopInlay(block)
@@ -111,7 +111,7 @@ internal class TerminalBlocksDecorator(
}
private fun createFinishedBlockDecoration(block: TerminalCommandBlock): BlockDecoration {
val startOffset = block.startOffset
val startOffset = block.startOffset.coerceAtLeast(outputModel.startOffset)
// End offset of the finished block is located after the line break.
// But we need to place the end inlay before the line break and limit the height of the highlighters to the block content.
// So adjust the offset by 1.