IJPL-176818 [reworked terminal] Update cursor on document changes

This fixes the case when the cursor offset hasn't changed because
something was appended to the document and the same number
of characters was removed from the beginning to maintain the size.
The offset stays the same, and therefore isn't emitted from the flow.
In such cases the cursor would only be repainted later due to
some other event, such as blinking.

GitOrigin-RevId: 5eb1dc1c6adfd3854c1290cd31806f48a1a0edee
This commit is contained in:
Sergei Tachenov
2025-02-11 18:15:16 +00:00
committed by intellij-monorepo-bot
parent f649d7c949
commit 9ec1bd4f5a
@@ -78,6 +78,17 @@ internal class TerminalCursorPainter private constructor(
updateCursor(curCursorState)
}
}, coroutineScope.asDisposable())
// Handling the case when:
// 0. The cursor is at the end of the document.
// 1. Something was appended to the document.
// 2. An equal amount of text was removed from the beginning, so that the max document size is maintained.
// 3. As a result, the logical offset of the cursor stayed the same, but we still need to repaint it.
outputModel.addListener(coroutineScope.asDisposable(), object : TerminalOutputModelListener {
override fun afterContentChanged(startOffset: Int) {
updateCursor(curCursorState)
}
})
}
@RequiresEdt