Mercurial > vim
comparison src/ex_getln.c @ 14417:5d9b450e7827 v8.1.0223
patch 8.1.0223: completing shell command finds sub-directories in $PATH
commit https://github.com/vim/vim/commit/6ab9e429da18f4d784222a9f7dfafb7c0218b7eb
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 28 19:20:13 2018 +0200
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 28 Jul 2018 19:30:06 +0200 |
parents | c1fcfafa8d1a |
children | e4c553e9132b |
comparison
equal
deleted
inserted
replaced
14416:99e672e31c18 | 14417:5d9b450e7827 |
---|---|
5191 */ | 5191 */ |
5192 ga_init2(&ga, (int)sizeof(char *), 10); | 5192 ga_init2(&ga, (int)sizeof(char *), 10); |
5193 hash_init(&found_ht); | 5193 hash_init(&found_ht); |
5194 for (s = path; ; s = e) | 5194 for (s = path; ; s = e) |
5195 { | 5195 { |
5196 if (*s == NUL) | |
5197 { | |
5198 if (did_curdir) | |
5199 break; | |
5200 /* Find directories in the current directory, path is empty. */ | |
5201 did_curdir = TRUE; | |
5202 } | |
5203 else if (*s == '.') | |
5204 did_curdir = TRUE; | |
5205 | |
5206 #if defined(MSWIN) | 5196 #if defined(MSWIN) |
5207 e = vim_strchr(s, ';'); | 5197 e = vim_strchr(s, ';'); |
5208 #else | 5198 #else |
5209 e = vim_strchr(s, ':'); | 5199 e = vim_strchr(s, ':'); |
5210 #endif | 5200 #endif |
5211 if (e == NULL) | 5201 if (e == NULL) |
5212 e = s + STRLEN(s); | 5202 e = s + STRLEN(s); |
5203 | |
5204 if (*s == NUL) | |
5205 { | |
5206 if (did_curdir) | |
5207 break; | |
5208 // Find directories in the current directory, path is empty. | |
5209 did_curdir = TRUE; | |
5210 flags |= EW_DIR; | |
5211 } | |
5212 else if (STRNCMP(s, ".", (int)(e - s)) == 0) | |
5213 { | |
5214 did_curdir = TRUE; | |
5215 flags |= EW_DIR; | |
5216 } | |
5217 else | |
5218 // Do not match directories inside a $PATH item. | |
5219 flags &= ~EW_DIR; | |
5213 | 5220 |
5214 l = e - s; | 5221 l = e - s; |
5215 if (l > MAXPATHL - 5) | 5222 if (l > MAXPATHL - 5) |
5216 break; | 5223 break; |
5217 vim_strncpy(buf, s, l); | 5224 vim_strncpy(buf, s, l); |
5264 return OK; | 5271 return OK; |
5265 } | 5272 } |
5266 | 5273 |
5267 | 5274 |
5268 # if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL) | 5275 # if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL) |
5269 static void * call_user_expand_func(void *(*user_expand_func)(char_u *, int, typval_T *, int), expand_T *xp, int *num_file, char_u ***file); | |
5270 | |
5271 /* | 5276 /* |
5272 * Call "user_expand_func()" to invoke a user defined Vim script function and | 5277 * Call "user_expand_func()" to invoke a user defined Vim script function and |
5273 * return the result (either a string or a List). | 5278 * return the result (either a string or a List). |
5274 */ | 5279 */ |
5275 static void * | 5280 static void * |