1
0
forked from aniani/vim

updated for version 7.3.072

Problem:    Can't complete file names while ignoring case.
Solution:   Add 'wildignorecase'.
This commit is contained in:
Bram Moolenaar 2010-12-02 16:01:29 +01:00
parent 4161dccada
commit 94950a9ee0
8 changed files with 45 additions and 10 deletions

View File

@ -7752,6 +7752,17 @@ A jump table for the options with a short description can be found at |Q_op|.
a pattern from the list. This avoids problems when a future version a pattern from the list. This avoids problems when a future version
uses another default. uses another default.
*'wildignorecase* *'wic'* *'nowildignorecase* *'nowic'*
'wildignorecase' 'wic' boolean (default off)
global
{not in Vi}
When set case is ignored when completing file names and directories.
Has no effect on systems where file name case is generally ignored.
Does not apply when the shell is used to expand wildcards, which
happens when there are special characters.
*'wildmenu'* *'wmnu'* *'nowildmenu'* *'nowmnu'* *'wildmenu'* *'wmnu'* *'nowildmenu'* *'nowmnu'*
'wildmenu' 'wmnu' boolean (default off) 'wildmenu' 'wmnu' boolean (default off)
global global

View File

@ -4524,12 +4524,14 @@ expand_filename(eap, cmdlinep, errormsgp)
else /* n == 2 */ else /* n == 2 */
{ {
expand_T xpc; expand_T xpc;
int options = WILD_LIST_NOTFOUND|WILD_ADD_SLASH;
ExpandInit(&xpc); ExpandInit(&xpc);
xpc.xp_context = EXPAND_FILES; xpc.xp_context = EXPAND_FILES;
if (p_wic)
options += WILD_ICASE;
p = ExpandOne(&xpc, eap->arg, NULL, p = ExpandOne(&xpc, eap->arg, NULL,
WILD_LIST_NOTFOUND|WILD_ADD_SLASH, options, WILD_EXPAND_FREE);
WILD_EXPAND_FREE);
if (p == NULL) if (p == NULL)
return FAIL; return FAIL;
} }

View File

@ -3339,10 +3339,14 @@ nextwild(xp, type, options)
p2 = NULL; p2 = NULL;
else else
{ {
int use_options = options |
WILD_HOME_REPLACE|WILD_ADD_SLASH|WILD_SILENT|WILD_ESCAPE;
if (p_wic)
use_options += WILD_ICASE;
p2 = ExpandOne(xp, p1, p2 = ExpandOne(xp, p1,
vim_strnsave(&ccline.cmdbuff[i], xp->xp_pattern_len), vim_strnsave(&ccline.cmdbuff[i], xp->xp_pattern_len),
WILD_HOME_REPLACE|WILD_ADD_SLASH|WILD_SILENT|WILD_ESCAPE use_options, type);
|options, type);
vim_free(p1); vim_free(p1);
/* longest match: make sure it is not shorter, happens with :help */ /* longest match: make sure it is not shorter, happens with :help */
if (p2 != NULL && type == WILD_LONGEST) if (p2 != NULL && type == WILD_LONGEST)
@ -3428,6 +3432,7 @@ nextwild(xp, type, options)
* options = WILD_KEEP_ALL: don't remove 'wildignore' entries * options = WILD_KEEP_ALL: don't remove 'wildignore' entries
* options = WILD_SILENT: don't print warning messages * options = WILD_SILENT: don't print warning messages
* options = WILD_ESCAPE: put backslash before special chars * options = WILD_ESCAPE: put backslash before special chars
* options = WILD_ICASE: ignore case for files
* *
* The variables xp->xp_context and xp->xp_backslash must have been set! * The variables xp->xp_context and xp->xp_backslash must have been set!
*/ */
@ -4361,6 +4366,7 @@ expand_cmdline(xp, str, col, matchcount, matches)
char_u ***matches; /* return: array of pointers to matches */ char_u ***matches; /* return: array of pointers to matches */
{ {
char_u *file_str = NULL; char_u *file_str = NULL;
int options = WILD_ADD_SLASH|WILD_SILENT;
if (xp->xp_context == EXPAND_UNSUCCESSFUL) if (xp->xp_context == EXPAND_UNSUCCESSFUL)
{ {
@ -4379,9 +4385,11 @@ expand_cmdline(xp, str, col, matchcount, matches)
if (file_str == NULL) if (file_str == NULL)
return EXPAND_UNSUCCESSFUL; return EXPAND_UNSUCCESSFUL;
if (p_wic)
options += WILD_ICASE;
/* find all files that match the description */ /* find all files that match the description */
if (ExpandFromContext(xp, file_str, matchcount, matches, if (ExpandFromContext(xp, file_str, matchcount, matches, options) == FAIL)
WILD_ADD_SLASH|WILD_SILENT) == FAIL)
{ {
*matchcount = 0; *matchcount = 0;
*matches = NULL; *matches = NULL;
@ -4433,7 +4441,7 @@ ExpandFromContext(xp, pat, num_file, file, options)
char_u *pat; char_u *pat;
int *num_file; int *num_file;
char_u ***file; char_u ***file;
int options; int options; /* EW_ flags */
{ {
#ifdef FEAT_CMDL_COMPL #ifdef FEAT_CMDL_COMPL
regmatch_T regmatch; regmatch_T regmatch;
@ -4487,6 +4495,9 @@ ExpandFromContext(xp, pat, num_file, file, options)
flags |= (EW_FILE | EW_PATH); flags |= (EW_FILE | EW_PATH);
else else
flags = (flags | EW_DIR) & ~EW_FILE; flags = (flags | EW_DIR) & ~EW_FILE;
if (options & WILD_ICASE)
flags |= EW_ICASE;
/* Expand wildcards, supporting %:h and the like. */ /* Expand wildcards, supporting %:h and the like. */
ret = expand_wildcards_eval(&pat, num_file, file, flags); ret = expand_wildcards_eval(&pat, num_file, file, flags);
if (free_pat) if (free_pat)

View File

@ -9161,7 +9161,10 @@ unix_expandpath(gap, path, wildoff, flags, didstar)
#ifdef CASE_INSENSITIVE_FILENAME #ifdef CASE_INSENSITIVE_FILENAME
regmatch.rm_ic = TRUE; /* Behave like Terminal.app */ regmatch.rm_ic = TRUE; /* Behave like Terminal.app */
#else #else
regmatch.rm_ic = FALSE; /* Don't ever ignore case */ if (flags & EW_ICASE)
regmatch.rm_ic = TRUE; /* 'wildignorecase' set */
else
regmatch.rm_ic = FALSE; /* Don't ignore case */
#endif #endif
regmatch.regprog = vim_regcomp(pat, RE_MAGIC); regmatch.regprog = vim_regcomp(pat, RE_MAGIC);
vim_free(pat); vim_free(pat);
@ -9643,7 +9646,7 @@ expand_in_path(gap, pattern, flags)
if (paths == NULL) if (paths == NULL)
return 0; return 0;
files = globpath(paths, pattern, 0); files = globpath(paths, pattern, (flags & EW_ICASE) ? WILD_ICASE : 0);
vim_free(paths); vim_free(paths);
if (files == NULL) if (files == NULL)
return 0; return 0;

View File

@ -2740,7 +2740,7 @@ static struct vimoption
(char_u *)&p_wc, PV_NONE, (char_u *)&p_wc, PV_NONE,
{(char_u *)(long)Ctrl_E, (char_u *)(long)TAB} {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
SCRIPTID_INIT}, SCRIPTID_INIT},
{"wildcharm", "wcm", P_NUM|P_VI_DEF, {"wildcharm", "wcm", P_NUM|P_VI_DEF,
(char_u *)&p_wcm, PV_NONE, (char_u *)&p_wcm, PV_NONE,
{(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
{"wildignore", "wig", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, {"wildignore", "wig", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
@ -2750,6 +2750,9 @@ static struct vimoption
(char_u *)NULL, PV_NONE, (char_u *)NULL, PV_NONE,
#endif #endif
{(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
{"wildignorecase", "wic", P_BOOL|P_VI_DEF,
(char_u *)&p_wic, PV_NONE,
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
{"wildmenu", "wmnu", P_BOOL|P_VI_DEF, {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
#ifdef FEAT_WILDMENU #ifdef FEAT_WILDMENU
(char_u *)&p_wmnu, PV_NONE, (char_u *)&p_wmnu, PV_NONE,

View File

@ -872,6 +872,7 @@ EXTERN int p_wiv; /* 'weirdinvert' */
EXTERN char_u *p_ww; /* 'whichwrap' */ EXTERN char_u *p_ww; /* 'whichwrap' */
EXTERN long p_wc; /* 'wildchar' */ EXTERN long p_wc; /* 'wildchar' */
EXTERN long p_wcm; /* 'wildcharm' */ EXTERN long p_wcm; /* 'wildcharm' */
EXTERN long p_wic; /* 'wildignorecase' */
EXTERN char_u *p_wim; /* 'wildmode' */ EXTERN char_u *p_wim; /* 'wildmode' */
#ifdef FEAT_WILDMENU #ifdef FEAT_WILDMENU
EXTERN int p_wmnu; /* 'wildmenu' */ EXTERN int p_wmnu; /* 'wildmenu' */

View File

@ -714,6 +714,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
72,
/**/ /**/
71, 71,
/**/ /**/

View File

@ -798,6 +798,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
#define WILD_KEEP_ALL 32 #define WILD_KEEP_ALL 32
#define WILD_SILENT 64 #define WILD_SILENT 64
#define WILD_ESCAPE 128 #define WILD_ESCAPE 128
#define WILD_ICASE 256
/* Flags for expand_wildcards() */ /* Flags for expand_wildcards() */
#define EW_DIR 0x01 /* include directory names */ #define EW_DIR 0x01 /* include directory names */
@ -808,6 +809,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
#define EW_SILENT 0x20 /* don't print "1 returned" from shell */ #define EW_SILENT 0x20 /* don't print "1 returned" from shell */
#define EW_EXEC 0x40 /* executable files */ #define EW_EXEC 0x40 /* executable files */
#define EW_PATH 0x80 /* search in 'path' too */ #define EW_PATH 0x80 /* search in 'path' too */
#define EW_ICASE 0x100 /* ignore case */
/* Note: mostly EW_NOTFOUND and EW_SILENT are mutually exclusive: EW_NOTFOUND /* Note: mostly EW_NOTFOUND and EW_SILENT are mutually exclusive: EW_NOTFOUND
* is used when executing commands and EW_SILENT for interactive expanding. */ * is used when executing commands and EW_SILENT for interactive expanding. */