| author | |
| committer | |
| log | 24c842936bc2637a9e5aead76d3cfa1030a381c2 |
| tree | 0f67430f3fef57b2d97cf2c5a4e3210bac8303fb |
| parent | 8f6b21a12e8c6509649883da8e36d375e5aa1fdf |
- 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 targets2 files changed, 31 insertions(+), 1 deletions(-)
apps/server/src/open.test.ts+22| ... | @@ -18,6 +18,28 @@ describe("resolveEditorLaunch", () => { | ... | @@ -18,6 +18,28 @@ describe("resolveEditorLaunch", () => { |
| 18 | }), | 18 | }), |
| 19 | ); | 19 | ); |
| 20 | 20 | ||
| 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 | |||
| 21 | it.effect("maps file-manager editor to OS open commands", () => | 43 | it.effect("maps file-manager editor to OS open commands", () => |
| 22 | Effect.gen(function* () { | 44 | Effect.gen(function* () { |
| 23 | const launch1 = yield* resolveEditorLaunch( | 45 | const launch1 = yield* resolveEditorLaunch( |
apps/server/src/open.ts+9-1| ... | @@ -30,6 +30,12 @@ interface EditorLaunch { | ... | @@ -30,6 +30,12 @@ interface EditorLaunch { |
| 30 | readonly args: ReadonlyArray<string>; | 30 | readonly args: ReadonlyArray<string>; |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | const LINE_COLUMN_SUFFIX_PATTERN = /:\d+(?::\d+)?$/; | ||
| 34 | |||
| 35 | function shouldUseGotoFlag(editorId: EditorId, target: string): boolean { | ||
| 36 | return editorId === "cursor" && LINE_COLUMN_SUFFIX_PATTERN.test(target); | ||
| 37 | } | ||
| 38 | |||
| 33 | /** | 39 | /** |
| 34 | * OpenShape - Service API for browser and editor launch actions. | 40 | * OpenShape - Service API for browser and editor launch actions. |
| 35 | */ | 41 | */ |
| ... | @@ -66,7 +72,9 @@ export const resolveEditorLaunch = Effect.fnUntraced(function* ( | ... | @@ -66,7 +72,9 @@ export const resolveEditorLaunch = Effect.fnUntraced(function* ( |
| 66 | } | 72 | } |
| 67 | 73 | ||
| 68 | if (editorDef.command) { | 74 | 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] }; | ||
| 70 | } | 78 | } |
| 71 | 79 | ||
| 72 | if (editorDef.id !== "file-manager") { | 80 | if (editorDef.id !== "file-manager") { |