summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2010-07-11 20:46:53 +0200
committerBram Moolenaar <Bram@vim.org>2010-07-11 20:46:53 +0200
commita9dc375744c80d882d380c40bf05a8db6a17993e (patch)
tree82c973a7fb8792d775e9f972cdfe698cbf17edec /src
parenta3f41662865d5a0582c4ccd22a38317907b59154 (diff)
downloadvim-git-a9dc375744c80d882d380c40bf05a8db6a17993e.tar.gz
Make CTRL-L in command line mode respect 'ignorecase' and 'smartcase'. (Martin
Toft)
Diffstat (limited to 'src')
-rw-r--r--src/ex_getln.c5
-rw-r--r--src/misc1.c2
-rw-r--r--src/proto/search.pro1
-rw-r--r--src/search.c78
4 files changed, 47 insertions, 39 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c
index e6ed44a41..b2e89e192 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -1411,6 +1411,11 @@ getcmdline(firstc, count, indent)
&& !equalpos(curwin->w_cursor, old_cursor))
{
c = gchar_cursor();
+ /* If 'ignorecase' and 'smartcase' are set and the
+ * command line has no uppercase characters, convert
+ * the character to lowercase */
+ if (p_ic && p_scs && !pat_has_uppercase(ccline.cmdbuff))
+ c = MB_TOLOWER(c);
if (c != NUL)
{
if (c == firstc || vim_strchr((char_u *)(
diff --git a/src/misc1.c b/src/misc1.c
index 31511249b..d87696d5c 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -9606,7 +9606,7 @@ FreeWild(count, files)
}
/*
- * return TRUE when need to go to Insert mode because of 'insertmode'.
+ * Return TRUE when need to go to Insert mode because of 'insertmode'.
* Don't do this when still processing a command or a mapping.
* Don't do this when inside a ":normal" command.
*/
diff --git a/src/proto/search.pro b/src/proto/search.pro
index 76ae05419..7f3947ca6 100644
--- a/src/proto/search.pro
+++ b/src/proto/search.pro
@@ -6,6 +6,7 @@ void save_search_patterns __ARGS((void));
void restore_search_patterns __ARGS((void));
void free_search_patterns __ARGS((void));
int ignorecase __ARGS((char_u *pat));
+int pat_has_uppercase __ARGS((char_u *pat));
char_u *last_search_pat __ARGS((void));
void reset_search_dir __ARGS((void));
void set_last_search_pat __ARGS((char_u *s, int idx, int magic, int setlast));
diff --git a/src/search.c b/src/search.c
index 3ad9140c1..86958d477 100644
--- a/src/search.c
+++ b/src/search.c
@@ -365,56 +365,58 @@ free_search_patterns()
ignorecase(pat)
char_u *pat;
{
- char_u *p;
- int ic;
+ int ic = p_ic;
- ic = p_ic;
if (ic && !no_smartcase && p_scs
#ifdef FEAT_INS_EXPAND
&& !(ctrl_x_mode && curbuf->b_p_inf)
#endif
)
+ ic = !pat_has_uppercase(pat);
+ no_smartcase = FALSE;
+
+ return ic;
+}
+
+/*
+ * Return TRUE if patter "pat" has an uppercase character.
+ */
+ int
+pat_has_uppercase(pat)
+ char_u *pat;
+{
+ char_u *p = pat;
+
+ while (*p != NUL)
{
- /* don't ignore case if pattern has uppercase */
- for (p = pat; *p; )
- {
#ifdef FEAT_MBYTE
- int l;
+ int l;
- if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
- {
- if (enc_utf8 && utf_isupper(utf_ptr2char(p)))
- {
- ic = FALSE;
- break;
- }
- p += l;
- }
- else
+ if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
+ {
+ if (enc_utf8 && utf_isupper(utf_ptr2char(p)))
+ return TRUE;
+ p += l;
+ }
+ else
#endif
- if (*p == '\\')
- {
- if (p[1] == '_' && p[2] != NUL) /* skip "\_X" */
- p += 3;
- else if (p[1] == '%' && p[2] != NUL) /* skip "\%X" */
- p += 3;
- else if (p[1] != NUL) /* skip "\X" */
- p += 2;
- else
- p += 1;
- }
- else if (MB_ISUPPER(*p))
- {
- ic = FALSE;
- break;
- }
- else
- ++p;
+ if (*p == '\\')
+ {
+ if (p[1] == '_' && p[2] != NUL) /* skip "\_X" */
+ p += 3;
+ else if (p[1] == '%' && p[2] != NUL) /* skip "\%X" */
+ p += 3;
+ else if (p[1] != NUL) /* skip "\X" */
+ p += 2;
+ else
+ p += 1;
}
+ else if (MB_ISUPPER(*p))
+ return TRUE;
+ else
+ ++p;
}
- no_smartcase = FALSE;
-
- return ic;
+ return FALSE;
}
char_u *