From f86c95ebdbd1851bcbf0e6f22d18a348a8a154ed Mon Sep 17 00:00:00 2001 From: liuk Date: Sat, 8 Mar 2025 23:27:04 +0800 Subject: [PATCH] fix: Ensure valid line index for highlighter --- .../continueintellijextension/editor/DiffStreamHandler.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt index e44c08dd5..55df303a8 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt @@ -13,6 +13,7 @@ import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.fileEditor.TextEditor import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile +import kotlin.math.max import kotlin.math.min @@ -179,7 +180,7 @@ class DiffStreamHandler( // Update the highlighter to show the current line curLine.highlighter?.let { editor.markupModel.removeHighlighter(it) } curLine.highlighter = editor.markupModel.addLineHighlighter( - curLineKey, min(curLine.index, editor.document.lineCount - 1), HighlighterLayer.LAST + curLineKey, min(curLine.index, max(0, editor.document.lineCount - 1)), HighlighterLayer.LAST ) // Remove the unfinished lines highlighter