Mercurial > vim
diff src/ex_getln.c @ 6695:6529590f6c43 v7.4.672
updated for version 7.4.672
Problem: When completing a shell command, directories in the current
directory are not listed.
Solution: When "." is not in $PATH also look in the current directory for
directories.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sat, 21 Mar 2015 17:32:19 +0100 |
parents | 6f1e4b7942c3 |
children | 5f6077b10738 |
line wrap: on
line diff
--- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -4885,6 +4885,7 @@ expand_shellcmd(filepat, num_file, file, char_u *s, *e; int flags = flagsarg; int ret; + int did_curdir = FALSE; if (buf == NULL) return FAIL; @@ -4896,7 +4897,7 @@ expand_shellcmd(filepat, num_file, file, if (pat[i] == '\\' && pat[i + 1] == ' ') STRMOVE(pat + i, pat + i + 1); - flags |= EW_FILE | EW_EXEC; + flags |= EW_FILE | EW_EXEC | EW_SHELLCMD; /* For an absolute name we don't use $PATH. */ if (mch_isFullName(pat)) @@ -4913,11 +4914,22 @@ expand_shellcmd(filepat, num_file, file, /* * Go over all directories in $PATH. Expand matches in that directory and - * collect them in "ga". + * collect them in "ga". When "." is not in $PATH also expand for the + * current directory, to find "subdir/cmd". */ ga_init2(&ga, (int)sizeof(char *), 10); - for (s = path; *s != NUL; s = e) + for (s = path; ; s = e) { + if (*s == NUL) + { + if (did_curdir) + break; + /* Find directories in the current directory, path is empty. */ + did_curdir = TRUE; + } + else if (*s == '.') + did_curdir = TRUE; + if (*s == ' ') ++s; /* Skip space used for absolute path name. */