From 24c842936bc2637a9e5aead76d3cfa1030a381c2 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 26 Feb 2026 15:46:20 -0800 Subject: [PATCH] Use Cursor --goto for file targets with line and column - detect `:line` and `:line:column` suffixes in open targets - pass `--goto` when launching Cursor so it jumps to the cursor location - add tests covering both line-only and line+column targets --- apps/server/src/open.test.ts | 22 ++++++++++++++++++++++ apps/server/src/open.ts | 10 +++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/apps/server/src/open.test.ts b/apps/server/src/open.test.ts index 617ed553599e69a13003a6ca1e1e0144e50197dc..2ab65b90ea82eb628a0244e9e4d3edb75a9bdeae 100644 --- a/apps/server/src/open.test.ts +++ b/apps/server/src/open.test.ts @@ -18,6 +18,28 @@ describe("resolveEditorLaunch", () => { }), ); + it.effect("uses --goto when cursor target includes line/column suffixes", () => + Effect.gen(function* () { + const lineOnly = yield* resolveEditorLaunch( + { cwd: "/tmp/workspace/AGENTS.md:48", editor: "cursor" }, + "darwin", + ); + assert.deepEqual(lineOnly, { + command: "cursor", + args: ["--goto", "/tmp/workspace/AGENTS.md:48"], + }); + + const lineAndColumn = yield* resolveEditorLaunch( + { cwd: "/tmp/workspace/src/open.ts:71:5", editor: "cursor" }, + "darwin", + ); + assert.deepEqual(lineAndColumn, { + command: "cursor", + args: ["--goto", "/tmp/workspace/src/open.ts:71:5"], + }); + }), + ); + it.effect("maps file-manager editor to OS open commands", () => Effect.gen(function* () { const launch1 = yield* resolveEditorLaunch( diff --git a/apps/server/src/open.ts b/apps/server/src/open.ts index 7e318b042e2210b4675df6637048ca89f51ddd56..a3ce1e87a96901b74ea33a282df4c503ba1b22cb 100644 --- a/apps/server/src/open.ts +++ b/apps/server/src/open.ts @@ -30,6 +30,12 @@ interface EditorLaunch { readonly args: ReadonlyArray; } +const LINE_COLUMN_SUFFIX_PATTERN = /:\d+(?::\d+)?$/; + +function shouldUseGotoFlag(editorId: EditorId, target: string): boolean { + return editorId === "cursor" && LINE_COLUMN_SUFFIX_PATTERN.test(target); +} + /** * OpenShape - Service API for browser and editor launch actions. */ @@ -66,7 +72,9 @@ export const resolveEditorLaunch = Effect.fnUntraced(function* ( } if (editorDef.command) { - return { command: editorDef.command, args: [input.cwd] }; + return shouldUseGotoFlag(editorDef.id, input.cwd) + ? { command: editorDef.command, args: ["--goto", input.cwd] } + : { command: editorDef.command, args: [input.cwd] }; } if (editorDef.id !== "file-manager") { -- 2.54.0