summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <bram@vim.org>2010-12-02 16:01:29 +0100
committerBram Moolenaar <bram@vim.org>2010-12-02 16:01:29 +0100
commit57cbac362d45e21ca11a00ec485cd974c3fc2ce4 (patch)
tree39243d891e9ca7479d67e5a3a063960fe35a97b0
parentf8e313dde7956f273af4a0f5518ef24fe6f87e4a (diff)
downloadvim-57cbac362d45e21ca11a00ec485cd974c3fc2ce4.tar.gz
updated for version 7.3.072v7.3.072v7-3-072
Problem: Can't complete file names while ignoring case. Solution: Add 'wildignorecase'.
-rw-r--r--runtime/doc/options.txt11
-rw-r--r--src/ex_docmd.c6
-rw-r--r--src/ex_getln.c21
-rw-r--r--src/misc1.c7
-rw-r--r--src/option.c5
-rw-r--r--src/option.h1
-rw-r--r--src/version.c2
-rw-r--r--src/vim.h2
8 files changed, 45 insertions, 10 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index db3ea35d..425f9831 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -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
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' boolean (default off)
global
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 0aac8f85..3265860f 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -4524,12 +4524,14 @@ expand_filename(eap, cmdlinep, errormsgp)
else /* n == 2 */
{
expand_T xpc;
+ int options = WILD_LIST_NOTFOUND|WILD_ADD_SLASH;
ExpandInit(&xpc);
xpc.xp_context = EXPAND_FILES;
+ if (p_wic)
+ options += WILD_ICASE;
p = ExpandOne(&xpc, eap->arg, NULL,
- WILD_LIST_NOTFOUND|WILD_ADD_SLASH,
- WILD_EXPAND_FREE);
+ options, WILD_EXPAND_FREE);
if (p == NULL)
return FAIL;
}
diff --git a/src/ex_getln.c b/src/ex_getln.c
index dfc6dffc..66d2ec44 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -3339,10 +3339,14 @@ nextwild(xp, type, options)
p2 = NULL;
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,
vim_strnsave(&ccline.cmdbuff[i], xp->xp_pattern_len),
- WILD_HOME_REPLACE|WILD_ADD_SLASH|WILD_SILENT|WILD_ESCAPE
- |options, type);
+ use_options, type);
vim_free(p1);
/* longest match: make sure it is not shorter, happens with :help */
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_SILENT: don't print warning messages
* 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!
*/
@@ -4361,6 +4366,7 @@ expand_cmdline(xp, str, col, matchcount, matches)
char_u ***matches; /* return: array of pointers to matches */
{
char_u *file_str = NULL;
+ int options = WILD_ADD_SLASH|WILD_SILENT;
if (xp->xp_context == EXPAND_UNSUCCESSFUL)
{
@@ -4379,9 +4385,11 @@ expand_cmdline(xp, str, col, matchcount, matches)
if (file_str == NULL)
return EXPAND_UNSUCCESSFUL;
+ if (p_wic)
+ options += WILD_ICASE;
+
/* find all files that match the description */
- if (ExpandFromContext(xp, file_str, matchcount, matches,
- WILD_ADD_SLASH|WILD_SILENT) == FAIL)
+ if (ExpandFromContext(xp, file_str, matchcount, matches, options) == FAIL)
{
*matchcount = 0;
*matches = NULL;
@@ -4433,7 +4441,7 @@ ExpandFromContext(xp, pat, num_file, file, options)
char_u *pat;
int *num_file;
char_u ***file;
- int options;
+ int options; /* EW_ flags */
{
#ifdef FEAT_CMDL_COMPL
regmatch_T regmatch;
@@ -4487,6 +4495,9 @@ ExpandFromContext(xp, pat, num_file, file, options)
flags |= (EW_FILE | EW_PATH);
else
flags = (flags | EW_DIR) & ~EW_FILE;
+ if (options & WILD_ICASE)
+ flags |= EW_ICASE;
+
/* Expand wildcards, supporting %:h and the like. */
ret = expand_wildcards_eval(&pat, num_file, file, flags);
if (free_pat)
diff --git a/src/misc1.c b/src/misc1.c
index 0859dc75..b14f2ed1 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -9161,7 +9161,10 @@ unix_expandpath(gap, path, wildoff, flags, didstar)
#ifdef CASE_INSENSITIVE_FILENAME
regmatch.rm_ic = TRUE; /* Behave like Terminal.app */
#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
regmatch.regprog = vim_regcomp(pat, RE_MAGIC);
vim_free(pat);
@@ -9643,7 +9646,7 @@ expand_in_path(gap, pattern, flags)
if (paths == NULL)
return 0;
- files = globpath(paths, pattern, 0);
+ files = globpath(paths, pattern, (flags & EW_ICASE) ? WILD_ICASE : 0);
vim_free(paths);
if (files == NULL)
return 0;
diff --git a/src/option.c b/src/option.c
index c8572d00..419ef68e 100644
--- a/src/option.c
+++ b/src/option.c
@@ -2740,7 +2740,7 @@ static struct vimoption
(char_u *)&p_wc, PV_NONE,
{(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
SCRIPTID_INIT},
- {"wildcharm", "wcm", P_NUM|P_VI_DEF,
+ {"wildcharm", "wcm", P_NUM|P_VI_DEF,
(char_u *)&p_wcm, PV_NONE,
{(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
{"wildignore", "wig", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
@@ -2750,6 +2750,9 @@ static struct vimoption
(char_u *)NULL, PV_NONE,
#endif
{(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,
#ifdef FEAT_WILDMENU
(char_u *)&p_wmnu, PV_NONE,
diff --git a/src/option.h b/src/option.h
index 0f697c2e..ce911b81 100644
--- a/src/option.h
+++ b/src/option.h
@@ -872,6 +872,7 @@ EXTERN int p_wiv; /* 'weirdinvert' */
EXTERN char_u *p_ww; /* 'whichwrap' */
EXTERN long p_wc; /* 'wildchar' */
EXTERN long p_wcm; /* 'wildcharm' */
+EXTERN long p_wic; /* 'wildignorecase' */
EXTERN char_u *p_wim; /* 'wildmode' */
#ifdef FEAT_WILDMENU
EXTERN int p_wmnu; /* 'wildmenu' */
diff --git a/src/version.c b/src/version.c
index 339b8eb4..85128805 100644
--- a/src/version.c
+++ b/src/version.c
@@ -715,6 +715,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 72,
+/**/
71,
/**/
70,
diff --git a/src/vim.h b/src/vim.h
index 5b742033..c799cce9 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -798,6 +798,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
#define WILD_KEEP_ALL 32
#define WILD_SILENT 64
#define WILD_ESCAPE 128
+#define WILD_ICASE 256
/* Flags for expand_wildcards() */
#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_EXEC 0x40 /* executable files */
#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
* is used when executing commands and EW_SILENT for interactive expanding. */