authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-02-26 15:46:20-08:00
committergravatar for jmarminge@gmail.comJulius Marminge <jmarminge@gmail.com> 2026-02-26 16:54:04-08:00
log24c842936bc2637a9e5aead76d3cfa1030a381c2
tree0f67430f3fef57b2d97cf2c5a4e3210bac8303fb
parent8f6b21a12e8c6509649883da8e36d375e5aa1fdf

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

2 files changed, 31 insertions(+), 1 deletions(-)

apps/server/src/open.test.ts+22
......@@ -18,6 +18,28 @@ describe("resolveEditorLaunch", () => {
1818 }),
1919 );
2020
21 it.effect("uses --goto when cursor target includes line/column suffixes", () =>
22 Effect.gen(function* () {
23 const lineOnly = yield* resolveEditorLaunch(
24 { cwd: "/tmp/workspace/AGENTS.md:48", editor: "cursor" },
25 "darwin",
26 );
27 assert.deepEqual(lineOnly, {
28 command: "cursor",
29 args: ["--goto", "/tmp/workspace/AGENTS.md:48"],
30 });
31
32 const lineAndColumn = yield* resolveEditorLaunch(
33 { cwd: "/tmp/workspace/src/open.ts:71:5", editor: "cursor" },
34 "darwin",
35 );
36 assert.deepEqual(lineAndColumn, {
37 command: "cursor",
38 args: ["--goto", "/tmp/workspace/src/open.ts:71:5"],
39 });
40 }),
41 );
42
2143 it.effect("maps file-manager editor to OS open commands", () =>
2244 Effect.gen(function* () {
2345 const launch1 = yield* resolveEditorLaunch(
apps/server/src/open.ts+9-1
......@@ -30,6 +30,12 @@ interface EditorLaunch {
3030 readonly args: ReadonlyArray<string>;
3131}
3232
33const LINE_COLUMN_SUFFIX_PATTERN = /:\d+(?::\d+)?$/;
34
35function shouldUseGotoFlag(editorId: EditorId, target: string): boolean {
36 return editorId === "cursor" && LINE_COLUMN_SUFFIX_PATTERN.test(target);
37}
38
3339/**
3440 * OpenShape - Service API for browser and editor launch actions.
3541 */
......@@ -66,7 +72,9 @@ export const resolveEditorLaunch = Effect.fnUntraced(function* (
6672 }
6773
6874 if (editorDef.command) {
69 return { command: editorDef.command, args: [input.cwd] };
75 return shouldUseGotoFlag(editorDef.id, input.cwd)
76 ? { command: editorDef.command, args: ["--goto", input.cwd] }
77 : { command: editorDef.command, args: [input.cwd] };
7078 }
7179
7280 if (editorDef.id !== "file-manager") {