@@ -16,6 +16,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => {
1616 const antigravityLaunch = yield * resolveEditorLaunch (
1717 { cwd : "/tmp/workspace" , editor : "antigravity" } ,
1818 "darwin" ,
19+ { PATH : "" } ,
1920 ) ;
2021 assert . deepEqual ( antigravityLaunch , {
2122 command : "agy" ,
@@ -25,6 +26,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => {
2526 const cursorLaunch = yield * resolveEditorLaunch (
2627 { cwd : "/tmp/workspace" , editor : "cursor" } ,
2728 "darwin" ,
29+ { PATH : "" } ,
2830 ) ;
2931 assert . deepEqual ( cursorLaunch , {
3032 command : "cursor" ,
@@ -34,6 +36,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => {
3436 const vscodeLaunch = yield * resolveEditorLaunch (
3537 { cwd : "/tmp/workspace" , editor : "vscode" } ,
3638 "darwin" ,
39+ { PATH : "" } ,
3740 ) ;
3841 assert . deepEqual ( vscodeLaunch , {
3942 command : "code" ,
@@ -43,6 +46,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => {
4346 const zedLaunch = yield * resolveEditorLaunch (
4447 { cwd : "/tmp/workspace" , editor : "zed" } ,
4548 "darwin" ,
49+ { PATH : "" } ,
4650 ) ;
4751 assert . deepEqual ( zedLaunch , {
4852 command : "zed" ,
@@ -56,6 +60,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => {
5660 const lineOnly = yield * resolveEditorLaunch (
5761 { cwd : "/tmp/workspace/AGENTS.md:48" , editor : "cursor" } ,
5862 "darwin" ,
63+ { PATH : "" } ,
5964 ) ;
6065 assert . deepEqual ( lineOnly , {
6166 command : "cursor" ,
@@ -65,6 +70,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => {
6570 const lineAndColumn = yield * resolveEditorLaunch (
6671 { cwd : "/tmp/workspace/src/open.ts:71:5" , editor : "cursor" } ,
6772 "darwin" ,
73+ { PATH : "" } ,
6874 ) ;
6975 assert . deepEqual ( lineAndColumn , {
7076 command : "cursor" ,
@@ -74,6 +80,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => {
7480 const vscodeLineAndColumn = yield * resolveEditorLaunch (
7581 { cwd : "/tmp/workspace/src/open.ts:71:5" , editor : "vscode" } ,
7682 "darwin" ,
83+ { PATH : "" } ,
7784 ) ;
7885 assert . deepEqual ( vscodeLineAndColumn , {
7986 command : "code" ,
@@ -83,6 +90,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => {
8390 const zedLineAndColumn = yield * resolveEditorLaunch (
8491 { cwd : "/tmp/workspace/src/open.ts:71:5" , editor : "zed" } ,
8592 "darwin" ,
93+ { PATH : "" } ,
8694 ) ;
8795 assert . deepEqual ( zedLineAndColumn , {
8896 command : "zed" ,
@@ -91,11 +99,43 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => {
9199 } ) ,
92100 ) ;
93101
102+ it . effect ( "falls back to zeditor when zed is not installed" , ( ) =>
103+ Effect . gen ( function * ( ) {
104+ const fs = yield * FileSystem . FileSystem ;
105+ const path = yield * Path . Path ;
106+ const dir = yield * fs . makeTempDirectoryScoped ( { prefix : "t3-open-test-" } ) ;
107+ yield * fs . writeFileString ( path . join ( dir , "zeditor" ) , "#!/bin/sh\nexit 0\n" ) ;
108+ yield * fs . chmod ( path . join ( dir , "zeditor" ) , 0o755 ) ;
109+
110+ const result = yield * resolveEditorLaunch ( { cwd : "/tmp/workspace" , editor : "zed" } , "linux" , {
111+ PATH : dir ,
112+ } ) ;
113+
114+ assert . deepEqual ( result , {
115+ command : "zeditor" ,
116+ args : [ "/tmp/workspace" ] ,
117+ } ) ;
118+ } ) ,
119+ ) ;
120+
121+ it . effect ( "falls back to the primary command when no alias is installed" , ( ) =>
122+ Effect . gen ( function * ( ) {
123+ const result = yield * resolveEditorLaunch ( { cwd : "/tmp/workspace" , editor : "zed" } , "linux" , {
124+ PATH : "" ,
125+ } ) ;
126+ assert . deepEqual ( result , {
127+ command : "zed" ,
128+ args : [ "/tmp/workspace" ] ,
129+ } ) ;
130+ } ) ,
131+ ) ;
132+
94133 it . effect ( "maps file-manager editor to OS open commands" , ( ) =>
95134 Effect . gen ( function * ( ) {
96135 const launch1 = yield * resolveEditorLaunch (
97136 { cwd : "/tmp/workspace" , editor : "file-manager" } ,
98137 "darwin" ,
138+ { PATH : "" } ,
99139 ) ;
100140 assert . deepEqual ( launch1 , {
101141 command : "open" ,
@@ -105,6 +145,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => {
105145 const launch2 = yield * resolveEditorLaunch (
106146 { cwd : "C:\\workspace" , editor : "file-manager" } ,
107147 "win32" ,
148+ { PATH : "" } ,
108149 ) ;
109150 assert . deepEqual ( launch2 , {
110151 command : "explorer" ,
@@ -114,6 +155,7 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => {
114155 const launch3 = yield * resolveEditorLaunch (
115156 { cwd : "/tmp/workspace" , editor : "file-manager" } ,
116157 "linux" ,
158+ { PATH : "" } ,
117159 ) ;
118160 assert . deepEqual ( launch3 , {
119161 command : "xdg-open" ,
@@ -229,4 +271,22 @@ it.layer(NodeServices.layer)("resolveAvailableEditors", (it) => {
229271 assert . deepEqual ( editors , [ "cursor" , "file-manager" ] ) ;
230272 } ) ,
231273 ) ;
274+
275+ it . effect ( "includes zed when only the zeditor command is installed" , ( ) =>
276+ Effect . gen ( function * ( ) {
277+ const fs = yield * FileSystem . FileSystem ;
278+ const path = yield * Path . Path ;
279+ const dir = yield * fs . makeTempDirectoryScoped ( { prefix : "t3-editors-" } ) ;
280+
281+ yield * fs . writeFileString ( path . join ( dir , "zeditor" ) , "#!/bin/sh\nexit 0\n" ) ;
282+ yield * fs . writeFileString ( path . join ( dir , "xdg-open" ) , "#!/bin/sh\nexit 0\n" ) ;
283+ yield * fs . chmod ( path . join ( dir , "zeditor" ) , 0o755 ) ;
284+ yield * fs . chmod ( path . join ( dir , "xdg-open" ) , 0o755 ) ;
285+
286+ const editors = resolveAvailableEditors ( "linux" , {
287+ PATH : dir ,
288+ } ) ;
289+ assert . deepEqual ( editors , [ "zed" , "file-manager" ] ) ;
290+ } ) ,
291+ ) ;
232292} ) ;
0 commit comments