From f66409292574695cd99c7b7b2fc5a986a03bbb1d Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 11 Dec 2024 23:36:00 -0800 Subject: [PATCH] path -> uri: code to edit, some commands --- core/commands/util.ts | 4 ++-- core/util/uri.test.ts | 3 ++- gui/src/components/CodeToEditCard/CodeToEditListItem.tsx | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/commands/util.ts b/core/commands/util.ts index e1e9cd60e..a136d4df4 100644 --- a/core/commands/util.ts +++ b/core/commands/util.ts @@ -38,8 +38,8 @@ export function ctxItemToRifWithContents( if (nameSplit.length > 1) { const lines = nameSplit[1].split(")")[0].split("-"); - startLine = Number.parseInt(lines[0], 10); - endLine = Number.parseInt(lines[1], 10); + startLine = Number.parseInt(lines[0], 10) - 1; + endLine = Number.parseInt(lines[1], 10) - 1; } const rif: RangeInFileWithContents = { diff --git a/core/util/uri.test.ts b/core/util/uri.test.ts index f4f7409a4..1b5a7e2e0 100644 --- a/core/util/uri.test.ts +++ b/core/util/uri.test.ts @@ -1,3 +1,4 @@ +import { getLastNPathParts } from "."; import { getLastNUriRelativePathParts, getRelativePath, @@ -156,7 +157,7 @@ describe("getRelativePath", () => { describe("getLastNPathParts", () => { test("returns the last N parts of a filepath with forward slashes", () => { const filepath = "home/user/documents/project/file.txt"; - expect(getLastNUriRelativePathParts(filepath, 2)).toBe("project/file.txt"); + expect(getLastNPathParts(filepath, 2)).toBe("project/file.txt"); }); test("returns the last N parts of a filepath with backward slashes", () => { diff --git a/gui/src/components/CodeToEditCard/CodeToEditListItem.tsx b/gui/src/components/CodeToEditCard/CodeToEditListItem.tsx index f91300e74..295084ebb 100644 --- a/gui/src/components/CodeToEditCard/CodeToEditListItem.tsx +++ b/gui/src/components/CodeToEditCard/CodeToEditListItem.tsx @@ -37,6 +37,7 @@ export default function CodeToEditListItem({ }: CodeToEditListItemProps) { const [showCodeSnippet, setShowCodeSnippet] = useState(false); + const x = useMemo(() => {}, [code.contents, code.filepath]); const context = useMemo(() => { return rifWithContentsToContextItem({ contents: code.contents,