@@ -60,6 +60,7 @@ describe('editor utils', () => {
60
60
{ editor : 'windsurf' , command : 'windsurf' , win32Command : 'windsurf' } ,
61
61
{ editor : 'cursor' , command : 'cursor' , win32Command : 'cursor' } ,
62
62
{ editor : 'vim' , command : 'vim' , win32Command : 'vim' } ,
63
+ { editor : 'neovim' , command : 'nvim' , win32Command : 'nvim' } ,
63
64
{ editor : 'zed' , command : 'zed' , win32Command : 'zed' } ,
64
65
] ;
65
66
@@ -139,31 +140,41 @@ describe('editor utils', () => {
139
140
} ) ;
140
141
}
141
142
142
- it ( 'should return the correct command for vim' , ( ) => {
143
- const command = getDiffCommand ( 'old.txt' , 'new.txt' , 'vim' ) ;
144
- expect ( command ) . toEqual ( {
145
- command : 'vim' ,
146
- args : [
147
- '-d' ,
148
- '-i' ,
149
- 'NONE' ,
150
- '-c' ,
151
- 'wincmd h | set readonly | wincmd l' ,
152
- '-c' ,
153
- 'highlight DiffAdd cterm=bold ctermbg=22 guibg=#005f00 | highlight DiffChange cterm=bold ctermbg=24 guibg=#005f87 | highlight DiffText ctermbg=21 guibg=#0000af | highlight DiffDelete ctermbg=52 guibg=#5f0000' ,
154
- '-c' ,
155
- 'set showtabline=2 | set tabline=[Instructions]\\ :wqa(save\\ &\\ quit)\\ \\|\\ i/esc(toggle\\ edit\\ mode)' ,
156
- '-c' ,
157
- 'wincmd h | setlocal statusline=OLD\\ FILE' ,
158
- '-c' ,
159
- 'wincmd l | setlocal statusline=%#StatusBold#NEW\\ FILE\\ :wqa(save\\ &\\ quit)\\ \\|\\ i/esc(toggle\\ edit\\ mode)' ,
160
- '-c' ,
161
- 'autocmd WinClosed * wqa' ,
162
- 'old.txt' ,
163
- 'new.txt' ,
164
- ] ,
143
+ const terminalEditors : Array < {
144
+ editor : EditorType ;
145
+ command : string ;
146
+ } > = [
147
+ { editor : 'vim' , command : 'vim' } ,
148
+ { editor : 'neovim' , command : 'nvim' } ,
149
+ ] ;
150
+
151
+ for ( const { editor, command } of terminalEditors ) {
152
+ it ( `should return the correct command for ${ editor } ` , ( ) => {
153
+ const diffCommand = getDiffCommand ( 'old.txt' , 'new.txt' , editor ) ;
154
+ expect ( diffCommand ) . toEqual ( {
155
+ command,
156
+ args : [
157
+ '-d' ,
158
+ '-i' ,
159
+ 'NONE' ,
160
+ '-c' ,
161
+ 'wincmd h | set readonly | wincmd l' ,
162
+ '-c' ,
163
+ 'highlight DiffAdd cterm=bold ctermbg=22 guibg=#005f00 | highlight DiffChange cterm=bold ctermbg=24 guibg=#005f87 | highlight DiffText ctermbg=21 guibg=#0000af | highlight DiffDelete ctermbg=52 guibg=#5f0000' ,
164
+ '-c' ,
165
+ 'set showtabline=2 | set tabline=[Instructions]\\ :wqa(save\\ &\\ quit)\\ \\|\\ i/esc(toggle\\ edit\\ mode)' ,
166
+ '-c' ,
167
+ 'wincmd h | setlocal statusline=OLD\\ FILE' ,
168
+ '-c' ,
169
+ 'wincmd l | setlocal statusline=%#StatusBold#NEW\\ FILE\\ :wqa(save\\ &\\ quit)\\ \\|\\ i/esc(toggle\\ edit\\ mode)' ,
170
+ '-c' ,
171
+ 'autocmd WinClosed * wqa' ,
172
+ 'old.txt' ,
173
+ 'new.txt' ,
174
+ ] ,
175
+ } ) ;
165
176
} ) ;
166
- } ) ;
177
+ }
167
178
168
179
it ( 'should return null for an unsupported editor' , ( ) => {
169
180
// @ts -expect-error Testing unsupported editor
@@ -240,7 +251,7 @@ describe('editor utils', () => {
240
251
} ) ;
241
252
}
242
253
243
- const execSyncEditors : EditorType [ ] = [ 'vim' ] ;
254
+ const execSyncEditors : EditorType [ ] = [ 'vim' , 'neovim' ] ;
244
255
for ( const editor of execSyncEditors ) {
245
256
it ( `should call execSync for ${ editor } on non-windows` , async ( ) => {
246
257
Object . defineProperty ( process , 'platform' , { value : 'linux' } ) ;
@@ -293,6 +304,15 @@ describe('editor utils', () => {
293
304
expect ( allowEditorTypeInSandbox ( 'vim' ) ) . toBe ( true ) ;
294
305
} ) ;
295
306
307
+ it ( 'should allow neovim in sandbox mode' , ( ) => {
308
+ process . env . SANDBOX = 'sandbox' ;
309
+ expect ( allowEditorTypeInSandbox ( 'neovim' ) ) . toBe ( true ) ;
310
+ } ) ;
311
+
312
+ it ( 'should allow neovim when not in sandbox mode' , ( ) => {
313
+ expect ( allowEditorTypeInSandbox ( 'neovim' ) ) . toBe ( true ) ;
314
+ } ) ;
315
+
296
316
const guiEditors : EditorType [ ] = [
297
317
'vscode' ,
298
318
'vscodium' ,
@@ -348,5 +368,11 @@ describe('editor utils', () => {
348
368
process . env . SANDBOX = 'sandbox' ;
349
369
expect ( isEditorAvailable ( 'vim' ) ) . toBe ( true ) ;
350
370
} ) ;
371
+
372
+ it ( 'should return true for neovim when installed and in sandbox mode' , ( ) => {
373
+ ( execSync as Mock ) . mockReturnValue ( Buffer . from ( '/usr/bin/nvim' ) ) ;
374
+ process . env . SANDBOX = 'sandbox' ;
375
+ expect ( isEditorAvailable ( 'neovim' ) ) . toBe ( true ) ;
376
+ } ) ;
351
377
} ) ;
352
378
} ) ;
0 commit comments