| ... | ... | @@ -16,6 +16,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => { |
| 16 | 16 | const antigravityLaunch = yield* resolveEditorLaunch( |
| 17 | 17 | { cwd: "/tmp/workspace", editor: "antigravity" }, |
| 18 | 18 | "darwin", |
| 19 | { PATH: "" }, |
| 19 | 20 | ); |
| 20 | 21 | assert.deepEqual(antigravityLaunch, { |
| 21 | 22 | command: "agy", |
| ... | ... | @@ -25,6 +26,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => { |
| 25 | 26 | const cursorLaunch = yield* resolveEditorLaunch( |
| 26 | 27 | { cwd: "/tmp/workspace", editor: "cursor" }, |
| 27 | 28 | "darwin", |
| 29 | { PATH: "" }, |
| 28 | 30 | ); |
| 29 | 31 | assert.deepEqual(cursorLaunch, { |
| 30 | 32 | command: "cursor", |
| ... | ... | @@ -43,6 +45,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => { |
| 43 | 45 | const vscodeLaunch = yield* resolveEditorLaunch( |
| 44 | 46 | { cwd: "/tmp/workspace", editor: "vscode" }, |
| 45 | 47 | "darwin", |
| 48 | { PATH: "" }, |
| 46 | 49 | ); |
| 47 | 50 | assert.deepEqual(vscodeLaunch, { |
| 48 | 51 | command: "code", |
| ... | ... | @@ -70,6 +73,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => { |
| 70 | 73 | const zedLaunch = yield* resolveEditorLaunch( |
| 71 | 74 | { cwd: "/tmp/workspace", editor: "zed" }, |
| 72 | 75 | "darwin", |
| 76 | { PATH: "" }, |
| 73 | 77 | ); |
| 74 | 78 | assert.deepEqual(zedLaunch, { |
| 75 | 79 | command: "zed", |
| ... | ... | @@ -92,6 +96,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => { |
| 92 | 96 | const lineOnly = yield* resolveEditorLaunch( |
| 93 | 97 | { cwd: "/tmp/workspace/AGENTS.md:48", editor: "cursor" }, |
| 94 | 98 | "darwin", |
| 99 | { PATH: "" }, |
| 95 | 100 | ); |
| 96 | 101 | assert.deepEqual(lineOnly, { |
| 97 | 102 | command: "cursor", |
| ... | ... | @@ -101,6 +106,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => { |
| 101 | 106 | const lineAndColumn = yield* resolveEditorLaunch( |
| 102 | 107 | { cwd: "/tmp/workspace/src/open.ts:71:5", editor: "cursor" }, |
| 103 | 108 | "darwin", |
| 109 | { PATH: "" }, |
| 104 | 110 | ); |
| 105 | 111 | assert.deepEqual(lineAndColumn, { |
| 106 | 112 | command: "cursor", |
| ... | ... | @@ -119,6 +125,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => { |
| 119 | 125 | const vscodeLineAndColumn = yield* resolveEditorLaunch( |
| 120 | 126 | { cwd: "/tmp/workspace/src/open.ts:71:5", editor: "vscode" }, |
| 121 | 127 | "darwin", |
| 128 | { PATH: "" }, |
| 122 | 129 | ); |
| 123 | 130 | assert.deepEqual(vscodeLineAndColumn, { |
| 124 | 131 | command: "code", |
| ... | ... | @@ -146,6 +153,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => { |
| 146 | 153 | const zedLineAndColumn = yield* resolveEditorLaunch( |
| 147 | 154 | { cwd: "/tmp/workspace/src/open.ts:71:5", editor: "zed" }, |
| 148 | 155 | "darwin", |
| 156 | { PATH: "" }, |
| 149 | 157 | ); |
| 150 | 158 | assert.deepEqual(zedLineAndColumn, { |
| 151 | 159 | command: "zed", |
| ... | ... | @@ -155,6 +163,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => { |
| 155 | 163 | const zedLineOnly = yield* resolveEditorLaunch( |
| 156 | 164 | { cwd: "/tmp/workspace/AGENTS.md:48", editor: "zed" }, |
| 157 | 165 | "darwin", |
| 166 | { PATH: "" }, |
| 158 | 167 | ); |
| 159 | 168 | assert.deepEqual(zedLineOnly, { |
| 160 | 169 | command: "zed", |
| ... | ... | @@ -181,11 +190,43 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => { |
| 181 | 190 | }), |
| 182 | 191 | ); |
| 183 | 192 | |
| 193 | it.effect("falls back to zeditor when zed is not installed", () => |
| 194 | Effect.gen(function* () { |
| 195 | const fs = yield* FileSystem.FileSystem; |
| 196 | const path = yield* Path.Path; |
| 197 | const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-open-test-" }); |
| 198 | yield* fs.writeFileString(path.join(dir, "zeditor"), "#!/bin/sh\nexit 0\n"); |
| 199 | yield* fs.chmod(path.join(dir, "zeditor"), 0o755); |
| 200 | |
| 201 | const result = yield* resolveEditorLaunch({ cwd: "/tmp/workspace", editor: "zed" }, "linux", { |
| 202 | PATH: dir, |
| 203 | }); |
| 204 | |
| 205 | assert.deepEqual(result, { |
| 206 | command: "zeditor", |
| 207 | args: ["/tmp/workspace"], |
| 208 | }); |
| 209 | }), |
| 210 | ); |
| 211 | |
| 212 | it.effect("falls back to the primary command when no alias is installed", () => |
| 213 | Effect.gen(function* () { |
| 214 | const result = yield* resolveEditorLaunch({ cwd: "/tmp/workspace", editor: "zed" }, "linux", { |
| 215 | PATH: "", |
| 216 | }); |
| 217 | assert.deepEqual(result, { |
| 218 | command: "zed", |
| 219 | args: ["/tmp/workspace"], |
| 220 | }); |
| 221 | }), |
| 222 | ); |
| 223 | |
| 184 | 224 | it.effect("maps file-manager editor to OS open commands", () => |
| 185 | 225 | Effect.gen(function* () { |
| 186 | 226 | const launch1 = yield* resolveEditorLaunch( |
| 187 | 227 | { cwd: "/tmp/workspace", editor: "file-manager" }, |
| 188 | 228 | "darwin", |
| 229 | { PATH: "" }, |
| 189 | 230 | ); |
| 190 | 231 | assert.deepEqual(launch1, { |
| 191 | 232 | command: "open", |
| ... | ... | @@ -195,6 +236,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => { |
| 195 | 236 | const launch2 = yield* resolveEditorLaunch( |
| 196 | 237 | { cwd: "C:\\workspace", editor: "file-manager" }, |
| 197 | 238 | "win32", |
| 239 | { PATH: "" }, |
| 198 | 240 | ); |
| 199 | 241 | assert.deepEqual(launch2, { |
| 200 | 242 | command: "explorer", |
| ... | ... | @@ -204,6 +246,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => { |
| 204 | 246 | const launch3 = yield* resolveEditorLaunch( |
| 205 | 247 | { cwd: "/tmp/workspace", editor: "file-manager" }, |
| 206 | 248 | "linux", |
| 249 | { PATH: "" }, |
| 207 | 250 | ); |
| 208 | 251 | assert.deepEqual(launch3, { |
| 209 | 252 | command: "xdg-open", |
| ... | ... | @@ -321,4 +364,29 @@ it.layer(NodeServices.layer)("resolveAvailableEditors", (it) => { |
| 321 | 364 | assert.deepEqual(editors, ["trae", "vscode-insiders", "vscodium", "file-manager"]); |
| 322 | 365 | }), |
| 323 | 366 | ); |
| 367 | |
| 368 | it.effect("includes zed when only the zeditor command is installed", () => |
| 369 | Effect.gen(function* () { |
| 370 | const fs = yield* FileSystem.FileSystem; |
| 371 | const path = yield* Path.Path; |
| 372 | const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-editors-" }); |
| 373 | |
| 374 | yield* fs.writeFileString(path.join(dir, "zeditor"), "#!/bin/sh\nexit 0\n"); |
| 375 | yield* fs.writeFileString(path.join(dir, "xdg-open"), "#!/bin/sh\nexit 0\n"); |
| 376 | yield* fs.chmod(path.join(dir, "zeditor"), 0o755); |
| 377 | yield* fs.chmod(path.join(dir, "xdg-open"), 0o755); |
| 378 | |
| 379 | const editors = resolveAvailableEditors("linux", { |
| 380 | PATH: dir, |
| 381 | }); |
| 382 | assert.deepEqual(editors, ["zed", "file-manager"]); |
| 383 | }), |
| 384 | ); |
| 385 | |
| 386 | it("omits file-manager when the platform opener is unavailable", () => { |
| 387 | const editors = resolveAvailableEditors("linux", { |
| 388 | PATH: "", |
| 389 | }); |
| 390 | assert.deepEqual(editors, []); |
| 391 | }); |
| 324 | 392 | }); |