aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_cmdline.vim
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-11-25 00:34:52 -0500
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-11-25 03:29:49 -0500
commit226ad89a2cf46b9a11a38b3236e23bd3e4c9b94a (patch)
tree477d54dd8d6bdc0463baf8a17e16867a42a8e8f1 /src/nvim/testdir/test_cmdline.vim
parent7a0a2eb310a5568d6ee743d65f5ae12f60111c6e (diff)
downloadrneovim-226ad89a2cf46b9a11a38b3236e23bd3e4c9b94a.tar.gz
rneovim-226ad89a2cf46b9a11a38b3236e23bd3e4c9b94a.tar.bz2
rneovim-226ad89a2cf46b9a11a38b3236e23bd3e4c9b94a.zip
vim-patch:8.1.0223: completing shell command finds sub-directories in $PATH
Problem: Completing shell command finds sub-directories in $PATH. Solution: Remove EW_DIR when completing an item in $PATH. (Jason Franklin) https://github.com/vim/vim/commit/6ab9e429da18f4d784222a9f7dfafb7c0218b7eb
Diffstat (limited to 'src/nvim/testdir/test_cmdline.vim')
-rw-r--r--src/nvim/testdir/test_cmdline.vim25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index 0a3e6ae625..19bf9b18aa 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -301,7 +301,7 @@ func Test_getcompletion()
call assert_equal([], l)
let l = getcompletion('.', 'shellcmd')
- call assert_equal(['./', '../'], l[0:1])
+ call assert_equal(['./', '../'], filter(l, 'v:val =~ "\\./"'))
call assert_equal(-1, match(l[2:], '^\.\.\?/$'))
let root = has('win32') ? 'C:\\' : '/'
let l = getcompletion(root, 'shellcmd')
@@ -375,6 +375,29 @@ func Test_getcompletion()
call assert_fails('call getcompletion("", "burp")', 'E475:')
endfunc
+func Test_shellcmd_completion()
+ let save_path = $PATH
+
+ call mkdir('Xpathdir/Xpathsubdir', 'p')
+ call writefile([''], 'Xpathdir/Xfile.exe')
+ call setfperm('Xpathdir/Xfile.exe', 'rwx------')
+
+ " Set PATH to example directory without trailing slash.
+ let $PATH = getcwd() . '/Xpathdir'
+
+ " Test for the ":!<TAB>" case. Previously, this would include subdirs of
+ " dirs in the PATH, even though they won't be executed. We check that only
+ " subdirs of the PWD and executables from the PATH are included in the
+ " suggestions.
+ let actual = getcompletion('X', 'shellcmd')
+ let expected = map(filter(glob('*', 0, 1), 'isdirectory(v:val) && v:val[0] == "X"'), 'v:val . "/"')
+ call insert(expected, 'Xfile.exe')
+ call assert_equal(expected, actual)
+
+ call delete('Xpathdir', 'rf')
+ let $PATH = save_path
+endfunc
+
func Test_expand_star_star()
call mkdir('a/b', 'p')
call writefile(['asdfasdf'], 'a/b/fileXname')