From 93202d90e043e82ad283bdef1da4d40db420d678 Mon Sep 17 00:00:00 2001 From: Zhiming Ma Date: Thu, 28 Nov 2024 13:40:07 +0800 Subject: [PATCH] fix(intellij): fix line number when navigate to file context. (#3486) --- .../main/kotlin/com/tabbyml/intellijtabby/chat/ChatBrowser.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clients/intellij/src/main/kotlin/com/tabbyml/intellijtabby/chat/ChatBrowser.kt b/clients/intellij/src/main/kotlin/com/tabbyml/intellijtabby/chat/ChatBrowser.kt index 5e1e4d900240..c63fc500a1d9 100644 --- a/clients/intellij/src/main/kotlin/com/tabbyml/intellijtabby/chat/ChatBrowser.kt +++ b/clients/intellij/src/main/kotlin/com/tabbyml/intellijtabby/chat/ChatBrowser.kt @@ -226,7 +226,8 @@ class ChatBrowser(private val project: Project) : JBCefBrowser( ?: project.guessProjectDir()?.url?.let { project.findVirtualFile(it.appendUrlPathSegments(fileContext.filepath)) } ?: return invokeLater { - val descriptor = OpenFileDescriptor(project, virtualFile, fileContext.range.start, 0) + val lineNumber = (fileContext.range.start - 1).coerceAtLeast(0) + val descriptor = OpenFileDescriptor(project, virtualFile, lineNumber, 0) FileEditorManager.getInstance(project).openTextEditor(descriptor, true) } }