Mercurial > vim
comparison src/ex_getln.c @ 2243:03a5f2897db3 vim73
Fix completion of file names with '%' and '*'.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 01 Jun 2010 21:57:09 +0200 |
parents | a16af0072ea8 |
children | aafed4a4866f |
comparison
equal
deleted
inserted
replaced
2242:bc4685345719 | 2243:03a5f2897db3 |
---|---|
4089 { | 4089 { |
4090 char_u *retval; | 4090 char_u *retval; |
4091 int i, j; | 4091 int i, j; |
4092 int new_len; | 4092 int new_len; |
4093 char_u *tail; | 4093 char_u *tail; |
4094 int ends_in_star; | |
4094 | 4095 |
4095 if (context != EXPAND_FILES | 4096 if (context != EXPAND_FILES |
4096 && context != EXPAND_SHELLCMD | 4097 && context != EXPAND_SHELLCMD |
4097 && context != EXPAND_DIRECTORIES) | 4098 && context != EXPAND_DIRECTORIES) |
4098 { | 4099 { |
4179 * $ could be anywhere in the tail. | 4180 * $ could be anywhere in the tail. |
4180 * ` could be anywhere in the file name. | 4181 * ` could be anywhere in the file name. |
4181 * When the name ends in '$' don't add a star, remove the '$'. | 4182 * When the name ends in '$' don't add a star, remove the '$'. |
4182 */ | 4183 */ |
4183 tail = gettail(retval); | 4184 tail = gettail(retval); |
4185 ends_in_star = (len > 0 && retval[len - 1] == '*'); | |
4186 #ifndef BACKSLASH_IN_FILENAME | |
4187 for (i = len - 2; i >= 0; --i) | |
4188 { | |
4189 if (retval[i] != '\\') | |
4190 break; | |
4191 ends_in_star = !ends_in_star; | |
4192 } | |
4193 #endif | |
4184 if ((*retval != '~' || tail != retval) | 4194 if ((*retval != '~' || tail != retval) |
4185 && (len == 0 || retval[len - 1] != '*') | 4195 && !ends_in_star |
4186 && vim_strchr(tail, '$') == NULL | 4196 && vim_strchr(tail, '$') == NULL |
4187 && vim_strchr(retval, '`') == NULL) | 4197 && vim_strchr(retval, '`') == NULL) |
4188 retval[len++] = '*'; | 4198 retval[len++] = '*'; |
4189 else if (len > 0 && retval[len - 1] == '$') | 4199 else if (len > 0 && retval[len - 1] == '$') |
4190 --len; | 4200 --len; |