@@ -231,7 +231,7 @@ func Test_getcompletion()
231231 call assert_equal ([], l )
232232
233233 let l = getcompletion (' .' , ' shellcmd' )
234- call assert_equal ([' ./' , ' ../' ], l [ 0 : 1 ] )
234+ call assert_equal ([' ./' , ' ../' ], filter ( l , ' v:val =~ "\\./" ' ) )
235235 call assert_equal (-1 , match (l [2 :], ' ^\.\.\?/$' ))
236236 let root = has (' win32' ) ? ' C:\\' : ' /'
237237 let l = getcompletion (root, ' shellcmd' )
@@ -290,6 +290,29 @@ func Test_getcompletion()
290290 call assert_fails (' call getcompletion("", "burp")' , ' E475:' )
291291endfunc
292292
293+ func Test_shellcmd_completion ()
294+ let save_path = $PATH
295+
296+ call mkdir (' Xpathdir/Xpathsubdir' , ' p' )
297+ call writefile ([' ' ], ' Xpathdir/Xfile.exe' )
298+ call setfperm (' Xpathdir/Xfile.exe' , ' rwx------' )
299+
300+ " Set PATH to example directory without trailing slash.
301+ let $PATH = getcwd () . ' /Xpathdir'
302+
303+ " Test for the ":!<TAB>" case. Previously, this would include subdirs of
304+ " dirs in the PATH, even though they won't be executed. We check that only
305+ " subdirs of the PWD and executables from the PATH are included in the
306+ " suggestions.
307+ let actual = getcompletion (' X' , ' shellcmd' )
308+ let expected = map (filter (glob (' *' , 0 , 1 ), ' isdirectory(v:val) && v:val[0] == "X"' ), ' v:val . "/"' )
309+ call insert (expected, ' Xfile.exe' )
310+ call assert_equal (expected, actual)
311+
312+ call delete (' Xpathdir' , ' rf' )
313+ let $PATH = save_path
314+ endfunc
315+
293316func Test_expand_star_star ()
294317 call mkdir (' a/b' , ' p' )
295318 call writefile ([' asdfasdf' ], ' a/b/fileXname' )
0 commit comments