From 2ce182bc13a03c34d8954ed88ddf3c8031c76340 Mon Sep 17 00:00:00 2001 From: liangfung Date: Tue, 24 Dec 2024 12:09:55 +0800 Subject: [PATCH] update --- clients/vscode/src/chat/WebviewHelper.ts | 4 +--- clients/vscode/src/chat/utils.ts | 5 ++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/clients/vscode/src/chat/WebviewHelper.ts b/clients/vscode/src/chat/WebviewHelper.ts index 8a5a5ee261a7..dd98d2105cd6 100644 --- a/clients/vscode/src/chat/WebviewHelper.ts +++ b/clients/vscode/src/chat/WebviewHelper.ts @@ -640,9 +640,7 @@ export class WebviewHelper { } } - const targetRange = fileLocation.location - ? chatPanelLocationToVSCodeRange(fileLocation.location) ?? new Range(0, 0, 0, 0) - : new Range(0, 0, 0, 0); + const targetRange = chatPanelLocationToVSCodeRange(fileLocation.location) ?? new Range(0, 0, 0, 0); try { await commands.executeCommand( "editor.action.goToLocations", diff --git a/clients/vscode/src/chat/utils.ts b/clients/vscode/src/chat/utils.ts index 1721277345a9..fe76c49033d6 100644 --- a/clients/vscode/src/chat/utils.ts +++ b/clients/vscode/src/chat/utils.ts @@ -83,7 +83,10 @@ export function chatPanelLineRangeToVSCodeRange(lineRange: LineRange): VSCodeRan return new VSCodeRange(Math.max(0, lineRange.start - 1), 0, lineRange.end, 0); } -export function chatPanelLocationToVSCodeRange(location: Location): VSCodeRange | null { +export function chatPanelLocationToVSCodeRange(location: Location | undefined): VSCodeRange | null { + if (!location) { + return null + } if (typeof location === "number") { const position = new VSCodePosition(Math.max(0, location - 1), 0); return new VSCodeRange(position, position);