From ab74a4efbae2064877dde317f94de9d4fef0d28c Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 17 Dec 2024 14:24:57 -0800 Subject: [PATCH] off by one range rif error - fix clickable context items and symbols --- core/commands/util.ts | 5 +++-- extensions/vscode/package-lock.json | 4 ++-- gui/src/components/mainInput/resolveInput.ts | 2 +- gui/src/components/markdown/CodeSnippetPreview.tsx | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/core/commands/util.ts b/core/commands/util.ts index 2d0c8257e..1cd493fad 100644 --- a/core/commands/util.ts +++ b/core/commands/util.ts @@ -29,6 +29,7 @@ export function rifWithContentsToContextItem( export function ctxItemToRifWithContents( item: ContextItemWithId, + linesOffByOne = false, ): RangeInFileWithContents { let startLine = 0; let endLine = 0; @@ -37,8 +38,8 @@ export function ctxItemToRifWithContents( if (nameSplit.length > 1) { const lines = nameSplit[1].split(")")[0].split("-"); - startLine = Number.parseInt(lines[0], 10) - 1; - endLine = Number.parseInt(lines[1], 10) - 1; + startLine = Number.parseInt(lines[0], 10) - (linesOffByOne ? 1 : 0); + endLine = Number.parseInt(lines[1], 10) - (linesOffByOne ? 1 : 0); } const rif: RangeInFileWithContents = { diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 3b0d6b371..ca4edfc38 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.245", + "version": "0.9.246", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.245", + "version": "0.9.246", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/gui/src/components/mainInput/resolveInput.ts b/gui/src/components/mainInput/resolveInput.ts index 190dfbc80..1ee6ed86a 100644 --- a/gui/src/components/mainInput/resolveInput.ts +++ b/gui/src/components/mainInput/resolveInput.ts @@ -72,7 +72,7 @@ async function resolveEditorContent({ } else if (p.type === "codeBlock") { if (p.attrs?.item) { const contextItem = p.attrs.item as ContextItemWithId; - const rif = ctxItemToRifWithContents(contextItem); + const rif = ctxItemToRifWithContents(contextItem, true); // If not editing, include codeblocks in the prompt // If editing is handled by selectedCode below if (!contextItem.editing) { diff --git a/gui/src/components/markdown/CodeSnippetPreview.tsx b/gui/src/components/markdown/CodeSnippetPreview.tsx index a463c421e..816ba82a6 100644 --- a/gui/src/components/markdown/CodeSnippetPreview.tsx +++ b/gui/src/components/markdown/CodeSnippetPreview.tsx @@ -89,7 +89,7 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) { filepath: props.item.uri.value, }); } else if (props.item.id.providerTitle === "code") { - const rif = ctxItemToRifWithContents(props.item); + const rif = ctxItemToRifWithContents(props.item, true); ideMessenger.ide.showLines( rif.filepath, rif.range.start.line,