summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2006-02-22 21:25:37 +0000
committerBram Moolenaar <Bram@vim.org>2006-02-22 21:25:37 +0000
commitd1f56e68f1315687ff5b913e2577f11b0b620573 (patch)
treeadbac0a00c07ee933058543eb3f251a83e707624
parent238a564935abe36832b267f32b5487556c640d00 (diff)
updated for version 7.0204v7.0204
-rw-r--r--runtime/doc/editing.txt16
-rw-r--r--runtime/doc/eval.txt4
-rw-r--r--runtime/doc/index.txt6
-rw-r--r--runtime/doc/insert.txt10
-rw-r--r--runtime/doc/options.txt18
-rw-r--r--runtime/doc/tabpage.txt21
-rw-r--r--runtime/doc/tags3
-rw-r--r--runtime/doc/todo.txt19
-rw-r--r--runtime/doc/usr_41.txt6
-rw-r--r--runtime/doc/version7.txt25
-rw-r--r--runtime/doc/windows.txt5
-rw-r--r--src/buffer.c72
-rw-r--r--src/diff.c6
-rw-r--r--src/edit.c151
-rw-r--r--src/eval.c8
-rw-r--r--src/ex_cmds.c6
-rw-r--r--src/ex_cmds2.c10
-rw-r--r--src/ex_docmd.c2
-rw-r--r--src/fileio.c10
-rw-r--r--src/fold.c2
-rw-r--r--src/globals.h9
-rw-r--r--src/gui.c3
-rw-r--r--src/gui_beval.c2
-rw-r--r--src/hardcopy.c4
-rw-r--r--src/main.c5
-rw-r--r--src/mbyte.c5
-rw-r--r--src/misc1.c3
-rw-r--r--src/misc2.c5
-rw-r--r--src/normal.c53
-rw-r--r--src/ops.c5
-rw-r--r--src/option.c93
-rw-r--r--src/option.h2
-rw-r--r--src/proto/buffer.pro2
-rw-r--r--src/proto/edit.pro4
-rw-r--r--src/proto/option.pro3
-rw-r--r--src/proto/window.pro6
-rw-r--r--src/quickfix.c5
-rw-r--r--src/screen.c105
-rw-r--r--src/search.c4
-rw-r--r--src/structs.h12
-rw-r--r--src/term.c6
-rw-r--r--src/version.h4
-rw-r--r--src/vim.h1
-rw-r--r--src/window.c54
44 files changed, 612 insertions, 183 deletions
diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt
index b29504ced2..dc22930bf3 100644
--- a/runtime/doc/editing.txt
+++ b/runtime/doc/editing.txt
@@ -334,6 +334,22 @@ CTRL-^ Edit the alternate file (equivalent to ":e #").
(For {Visual} see |Visual-mode|.)
{not in VI}
+ *gF*
+[count]gF Same as "gf", except if a number follows the file
+ name, then the cursor is positioned on that line in
+ the file. The file name and the number must be
+ separated by a non-filename (see 'isfname') and
+ non-numeric character. White space between the
+ filename, the separator and the number are ignored.
+ Examples: >
+ eval.c:10
+ eval.c @ 20
+ eval.c (30)
+ eval.c 40
+<
+ *v_gF*
+{Visual}[count]gF Same as "v_gf".
+
These commands are used to start editing a single file. This means that the
file is read into the buffer and the current file name is set. The file that
is opened depends on the current directory, see |:cd|.
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 474f863323..adcd6f341d 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt* For Vim version 7.0aa. Last change: 2006 Feb 20
+*eval.txt* For Vim version 7.0aa. Last change: 2006 Feb 22
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -6928,7 +6928,7 @@ This is not guaranteed 100% secure, but it should block most attacks.
*sandbox-option*
A few options contain an expression. When this expression is evaluated it may
-have to be done in the sandbox to avoid trouble. But the sandbox is
+have to be done in the sandbox to avoid a security risc. But the sandbox is
restrictive, thus this only happens when the option was set from an insecure
location. Insecure in this context are:
- sourcing a .vimrc or .exrc in the current directlry
diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt
index b265ee61ae..fa4eca4e38 100644
--- a/runtime/doc/index.txt
+++ b/runtime/doc/index.txt
@@ -541,6 +541,9 @@ tag command action in Normal mode ~
the cursor
|CTRL-W_f| CTRL-W f split window and edit file name under the
cursor
+|CTRL-W_F| CTRL-W F split window and edit file name under the
+ cursor and jump to the line number
+ following the file name.
|CTRL-W_g_CTRL-]| CTRL-W g CTRL-] split window and do |:tjump| to tag under
cursor
|CTRL-W_g]| CTRL-W g ] split window and do |:tselect| for tag
@@ -719,6 +722,9 @@ tag char note action in Normal mode ~
word
|gf| gf start editing the file whose name is under
the cursor
+|gF| gF start editing the file whose name is under
+ the cursor and jump to the line number
+ following the filename.
|gg| gg 1 cursor to line N, default first line
|gh| gh start Select mode
|gi| gi 2 like "i", but first move to the |'^| mark
diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt
index 450f6670fd..5f551312b6 100644
--- a/runtime/doc/insert.txt
+++ b/runtime/doc/insert.txt
@@ -1,4 +1,4 @@
-*insert.txt* For Vim version 7.0aa. Last change: 2006 Feb 14
+*insert.txt* For Vim version 7.0aa. Last change: 2006 Feb 22
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -993,10 +993,12 @@ items:
menu extra text for the popup menu
info more information about the item
kind single letter indicating the type of completion
+ icase when not zero case is to be ignored; when omitted
+ the 'ignorecase' option is used
-All of these must be a string. If an item does not meet these requirements
-then an error message is given and further items in the list are not used.
-You can mix string and Dictionary items in the returned list.
+All of these except 'icase' must be a string. If an item does not meet these
+requirements then an error message is given and further items in the list are
+not used. You can mix string and Dictionary items in the returned list.
The "menu" item is used in the popup menu and may be truncated, thus it should
be relatively short. The "info" item can be longer, it may be displayed in a
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 53411ad49c..b8931aee3e 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1,4 +1,4 @@
-*options.txt* For Vim version 7.0aa. Last change: 2006 Feb 21
+*options.txt* For Vim version 7.0aa. Last change: 2006 Feb 22
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1629,7 +1629,9 @@ A jump table for the options with a short description can be found at |Q_op|.
sufficient colors are available. |ins-completion-menu|
longest Only insert the longest common text of the matches. Use
- CTRL-L to add more characters.
+ CTRL-L to add more characters. Whether case is ignored
+ depends on the kind of completion. For buffer text the
+ 'ignorecase' option is used.
*'confirm'* *'cf'* *'noconfirm'* *'nocf'*
@@ -2904,7 +2906,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|v:count| the number of lines to be formatted.
When this option is empty 'formatprg' is used.
Example: >
- :set formatexp=mylang#Format()
+ :set formatexpr=mylang#Format()
< This will invoke the mylang#Format() function in the
autoload/mylang.vim file in 'runtimepath'. |autoload|
@@ -6073,6 +6075,11 @@ A jump table for the options with a short description can be found at |Q_op|.
( - Start of item group. Can be used for setting the width and
alignment of a section. Must be followed by %) somewhere.
) - End of item group. No width fields allowed.
+ T N For 'tabline': start of tab page N label. Use %T after the last
+ label. This information is used for mouse clicks.
+ X N For 'tabline': start of close tab N label. Use %X after the
+ label, e.g.: %3Xclose%X. Use %999X for a "close current tab"
+ mark. This information is used for mouse clicks.
< - Where to truncate line if too long. Default is at the start.
No width fields allowed.
= - Separation point between left and right aligned items.
@@ -6269,14 +6276,15 @@ A jump table for the options with a short description can be found at |Q_op|.
feature}
When nonempty, this option determines the content of the tab pages
line at the top of the Vim window. When empty Vim will use a default
- tab pages line. |tab-page|
+ tab pages line. See |setting-tabline| for more info.
The tab pages line only appears as specified with the 'showtabline'
option and only when there is no GUI implementation for tabs.
The value is evaluated like with 'statusline'. You can use
|tabpagenr()|, |tabpagewinnr()| and |tabpagebuflist()| to figure out
- the text to be displayed. See |setting-tabline| for more info.
+ the text to be displayed. Use "%1T" for the first label, "%2T" for
+ the second one, etc. Use "%X" items for closing labels.
Keep in mind that only one of the tab pages is the current one, others
are invisible and you can't jump to their windows.
diff --git a/runtime/doc/tabpage.txt b/runtime/doc/tabpage.txt
index e0e8b17ede..2db521efa3 100644
--- a/runtime/doc/tabpage.txt
+++ b/runtime/doc/tabpage.txt
@@ -1,4 +1,4 @@
-*tabpage.txt* For Vim version 7.0aa. Last change: 2006 Feb 21
+*tabpage.txt* For Vim version 7.0aa. Last change: 2006 Feb 22
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -164,14 +164,28 @@ pages and define labels for them. Then get the label for each tab page. >
function MyTabLine()
let s = ''
for i in range(tabpagenr('$'))
+ " select the highlighting
if i + 1 == tabpagenr()
let s .= '%#TabLineSel#'
else
let s .= '%#TabLine#'
endif
+
+ " set the tab page number (for mouse clicks)
+ let s .= '%' . (i + 1) . 'T'
+
+ " the label is made by MyTabLabel()
let s .= ' %{MyTabLabel(' . (i + 1) . ')} '
endfor
- let s .= '%#TabLineFill#'
+
+ " after the last tab fill with TabLineFill and reset tab page nr
+ let s .= '%#TabLineFill#%T'
+
+ " right-align the label to close the current tab page
+ if tabpagenr('$') > 1
+ let s .= '%=%#TabLine#%999Xclose'
+ endif
+
return s
endfunction
@@ -187,7 +201,6 @@ This is just a simplistic example that results in a tab pages line that
resembles the default, but without adding a + for a modified buffer or
trunctating the names. You will want to reduce the width of labels in a
clever way when there is not enough room. Check the 'columns' option for the
-space available, keeping in mind that the "X" at the right will take one more
-position.
+space available.
vim:tw=78:ts=8:ft=help:norl:
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 630e0f880d..278e1ba9a2 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -3078,6 +3078,7 @@ CTRL-W_CTRL-Z windows.txt /*CTRL-W_CTRL-Z*
CTRL-W_CTRL-] windows.txt /*CTRL-W_CTRL-]*
CTRL-W_CTRL-^ windows.txt /*CTRL-W_CTRL-^*
CTRL-W_CTRL-_ windows.txt /*CTRL-W_CTRL-_*
+CTRL-W_F windows.txt /*CTRL-W_F*
CTRL-W_H windows.txt /*CTRL-W_H*
CTRL-W_J windows.txt /*CTRL-W_J*
CTRL-W_K windows.txt /*CTRL-W_K*
@@ -5285,6 +5286,7 @@ g?g? change.txt /*g?g?*
g@ map.txt /*g@*
gD pattern.txt /*gD*
gE motion.txt /*gE*
+gF editing.txt /*gF*
gH visual.txt /*gH*
gI insert.txt /*gI*
gJ change.txt /*gJ*
@@ -7283,6 +7285,7 @@ v_b_r_example visual.txt /*v_b_r_example*
v_c change.txt /*v_c*
v_d change.txt /*v_d*
v_g? change.txt /*v_g?*
+v_gF editing.txt /*v_gF*
v_gJ change.txt /*v_gJ*
v_gV visual.txt /*v_gV*
v_g] tagsrch.txt /*v_g]*
diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt
index 230ec6efcc..f50d04fbc1 100644
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1,4 +1,4 @@
-*todo.txt* For Vim version 7.0aa. Last change: 2006 Feb 21
+*todo.txt* For Vim version 7.0aa. Last change: 2006 Feb 22
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -30,18 +30,6 @@ be worked on, but only if you sponsor Vim development. See |sponsor|.
*known-bugs*
-------------------- Known bugs and current work -----------------------
-Remove resetting "bold" from screen_start_highlight()?
-
-Using 'tabline' breaks using mouse to select a tab. How to do that?
-See suggestion from Tony Mechelynck.
-
-P_INSECURE should be remembered for local option values separately.
-
-Completion: <Up> and <Down> don't insert completion, <PageUp> and <PageDown>
-shouldn't either.
-
-Completion: case sensitiveness when typing BS: make it an option?
-
Completion: When back at the original word behave like after BS.
Completion: When to get out of the BS state when the user keeps on typing?
@@ -89,11 +77,16 @@ windows. Let's call them "tab pages".
Crash with X command server (Ciaran McCreesh).
+Make virtcol([lnum, col]) work?
+
"dip" in end empty lines at end of file leaves one line. (Matt Mzyzik)
Ctags still hasn't included the patch. Darren is looking for someone to do
maintanance.
+Script ID is only remembered for global options. Should remember it for every
+local option separately.
+
"fsutil hardlink" can create a hard link on an NTFS file system. (Daniel
Einspanjer) What library function can detect that?
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index 62b6a917f9..c8c70559b6 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -1,4 +1,4 @@
-*usr_41.txt* For Vim version 7.0aa. Last change: 2005 Nov 30
+*usr_41.txt* For Vim version 7.0aa. Last change: 2006 Feb 22
VIM USER MANUAL - by Bram Moolenaar
@@ -834,7 +834,7 @@ For people who like short functions, this does the same thing: >
: return a:num2
:endfunction
-A user defined function is called in exactly the same way as a builtin
+A user defined function is called in exactly the same way as a built-in
function. Only the name is different. The Min function can be used like
this: >
@@ -2245,7 +2245,7 @@ organize your functions in library scripts. But you must use function names
where the part before the '#' matches the script name. Otherwise Vim would
not know what script to load.
-If you get really enthousiastic and write lots of library scripts, you may
+If you get really enthusiastic and write lots of library scripts, you may
want to use subdirectories. Example: >
call netlib#ftp#read('somefile')
diff --git a/runtime/doc/version7.txt b/runtime/doc/version7.txt
index 4d9fd51c1b..addb5a2234 100644
--- a/runtime/doc/version7.txt
+++ b/runtime/doc/version7.txt
@@ -1,4 +1,4 @@
-*version7.txt* For Vim version 7.0aa. Last change: 2006 Feb 21
+*version7.txt* For Vim version 7.0aa. Last change: 2006 Feb 22
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -388,6 +388,14 @@ CTRL-W <Enter> In the quickfix window: opens a new window to show the
<A-RightMouse> ('mousemodel' "extend")
Make a blockwise selection. |<A-LeftMouse>|
+gF Start editing the filename under the cursor and jump
+ to the line number following the file name.
+ (Yegappan Lakshmanan)
+
+CTRL-W F Start editing the filename under the cursor in a new
+ window and jump to the line number following the file
+ name. (Yegappan Lakshmanan)
+
Insert mode commands: ~
CTRL-\ CTRL-O Execute a Normal mode command. Like CTRL-O but
@@ -800,9 +808,6 @@ upper case. Add color support to the builtin vt320 terminal codes.
For the '%' item in 'viminfo', allow a number to set a maximum for the number
of buffers.
-The 'statusline' option can be local to the window, so that each window can
-have a different value. (partly by Yegappan Lakshmanan)
-
When a file looks like a shell script, check for an "exec" command that starts
the tcl interpreter. (suggested by Alexios Zavras)
@@ -1018,12 +1023,20 @@ Insert mode completion for whole lines now also searches unloaded buffers.
The colortest.vim script can now be invoked directly with ":source" or
":runtime".
+The 'statusline' option can be local to the window, so that each window can
+have a different value. (partly by Yegappan Lakshmanan)
+
The 'statusline' option and other options that support the same format can now
use these new features:
- When it starts with "%!" the value is first evaluated as an expression
before parsing the value.
- "%#HLname#" can be used to start highlighting with HLname.
+When 'statusline' is set to something that causes an error message then it is
+made empty to avoid an endless redraw loop. Also for other options, such at
+'tabline'. ":verbose set statusline" will mention that it was set in an error
+handler.
+
==============================================================================
COMPILE TIME CHANGES *compile-changes-7*
@@ -1722,4 +1735,8 @@ When editing in an xterm with a different number of colors than expected the
screen would be cleared and redrawn, causing the message about the edited file
to be cleared. Now set "keep_msg" to redraw the last message.
+For a color terminal: When the Normal HL uses bold, possibly to make the color
+lighter, and another HL group specifies a color it might become light as well.
+Now reset bold if a HL group doesn't specify bold itself.
+
vim:tw=78:ts=8:ft=help:norl:
diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt
index a83bdd2968..97e015e0c3 100644
--- a/runtime/doc/windows.txt
+++ b/runtime/doc/windows.txt
@@ -714,6 +714,11 @@ CTRL-W CTRL-F Split current window in two. Edit file name under cursor.
{not available when the |+file_in_path| feature was disabled
at compile time}
+CTRL-W F *CTRL-W_F*
+ Split current window in two. Edit file name under cursor and
+ jump to the line number following the file name. See |gF| for
+ details on how the line number is obtained.
+
Also see |CTRL-W_CTRL-I|: open window for an included file that includes
the keyword under the cursor.
diff --git a/src/buffer.c b/src/buffer.c
index 12ee1b3b53..101d33f831 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -3018,12 +3018,12 @@ maketitle()
int use_sandbox = FALSE;
# ifdef FEAT_EVAL
- use_sandbox = was_set_insecurely((char_u *)"titlestring");
+ use_sandbox = was_set_insecurely((char_u *)"titlestring", 0);
# endif
if (stl_syntax & STL_IN_TITLE)
build_stl_str_hl(curwin, t_str, sizeof(buf),
p_titlestring, use_sandbox,
- 0, maxlen, NULL);
+ 0, maxlen, NULL, NULL);
else
#endif
t_str = p_titlestring;
@@ -3115,12 +3115,12 @@ maketitle()
int use_sandbox = FALSE;
# ifdef FEAT_EVAL
- use_sandbox = was_set_insecurely((char_u *)"iconstring");
+ use_sandbox = was_set_insecurely((char_u *)"iconstring", 0);
# endif
if (stl_syntax & STL_IN_ICON)
build_stl_str_hl(curwin, i_str, sizeof(buf),
p_iconstring, use_sandbox,
- 0, 0, NULL);
+ 0, 0, NULL, NULL);
else
#endif
i_str = p_iconstring;
@@ -3213,7 +3213,7 @@ free_titles()
* or truncated if too long, fillchar is used for all whitespace.
*/
int
-build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hl)
+build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hltab, tabtab)
win_T *wp;
char_u *out; /* buffer to write into */
size_t outlen; /* length of out[] */
@@ -3221,7 +3221,8 @@ build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hl)
int use_sandbox; /* "fmt" was set insecurely, use sandbox */
int fillchar;
int maxwidth;
- struct stl_hlrec *hl;
+ struct stl_hlrec *hltab; /* return: HL attributes (can be NULL) */
+ struct stl_hlrec *tabtab; /* return: tab page nrs (can be NULL) */
{
char_u *p;
char_u *s;
@@ -3258,6 +3259,7 @@ build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hl)
Group,
Middle,
Highlight,
+ TabPage,
Trunc
} type;
} item[STL_MAX_ITEM];
@@ -3269,6 +3271,7 @@ build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hl)
#define TMPLEN 70
char_u tmp[TMPLEN];
char_u *usefmt = fmt;
+ struct stl_hlrec *sp;
#ifdef FEAT_EVAL
/*
@@ -3452,6 +3455,32 @@ build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hl)
curitem++;
continue;
}
+ if (*s == STL_TABPAGENR || *s == STL_TABCLOSENR)
+ {
+ if (*s == STL_TABCLOSENR)
+ {
+ if (minwid == 0)
+ {
+ /* %X ends the close label, go back to the previously
+ * define tab label nr. */
+ for (n = curitem - 1; n >= 0; --n)
+ if (item[n].type == TabPage && item[n].minwid >= 0)
+ {
+ minwid = item[n].minwid;
+ break;
+ }
+ }
+ else
+ /* close nrs are stored as negative values */
+ minwid = - minwid;
+ }
+ item[curitem].type = TabPage;
+ item[curitem].start = p;
+ item[curitem].minwid = minwid;
+ s++;
+ curitem++;
+ continue;
+ }
if (*s == '.')
{
s++;
@@ -3953,19 +3982,38 @@ build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hl)
}
}
- if (hl != NULL)
+ /* Store the info about highlighting. */
+ if (hltab != NULL)
{
+ sp = hltab;
for (l = 0; l < itemcnt; l++)
{
if (item[l].type == Highlight)
{
- hl->start = item[l].start;
- hl->userhl = item[l].minwid;
- hl++;
+ sp->start = item[l].start;
+ sp->userhl = item[l].minwid;
+ sp++;
+ }
+ }
+ sp->start = NULL;
+ sp->userhl = 0;
+ }
+
+ /* Store the info about tab pages labels. */
+ if (tabtab != NULL)
+ {
+ sp = tabtab;
+ for (l = 0; l < itemcnt; l++)
+ {
+ if (item[l].type == TabPage)
+ {
+ sp->start = item[l].start;
+ sp->userhl = item[l].minwid;
+ sp++;
}
}
- hl->start = NULL;
- hl->userhl = 0;
+ sp->start = NULL;
+ sp->userhl = 0;
}
return width;
diff --git a/src/diff.c b/src/diff.c
index 7170835d4b..b28e127ccf 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -1078,6 +1078,9 @@ diff_win_options(wp, addbuf)
curbuf = curwin->w_buffer;
set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff",
OPT_LOCAL|OPT_FREE);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"fdm", current_SID);
+# endif
curwin = old_curwin;
curbuf = curwin->w_buffer;
wp->w_p_fdc = 2;
@@ -1125,6 +1128,9 @@ ex_diffoff(eap)
curbuf = curwin->w_buffer;
set_string_option_direct((char_u *)"fdm", -1,
(char_u *)"manual", OPT_LOCAL|OPT_FREE);
+# ifdef FEAT_EVAL
+ set_option_scriptID((char_u *)"fdm", current_SID);
+# endif
curwin = old_curwin;
curbuf = curwin->w_buffer;
wp->w_p_fdc = 0;
diff --git a/src/edit.c b/src/edit.c
index b57b56707e..d159911bb0 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -62,12 +62,13 @@ static char_u e_hitend[] = N_("Hit end of paragraph");
/*
* Structure used to store one match for insert completion.
*/
-typedef struct Completion compl_T;
-struct Completion
+typedef struct compl_S compl_T;
+struct compl_S
{
compl_T *cp_next;
compl_T *cp_prev;
char_u *cp_str; /* matched text */
+ char cp_icase; /* TRUE or FALSE: ignore case */
char_u *cp_extra; /* extra menu text (allocated, can be NULL) */
char_u *cp_info; /* verbose info (can be NULL) */
char_u cp_kind; /* kind of match, single letter, or NUL */
@@ -121,8 +122,9 @@ static expand_T compl_xp;
static void ins_ctrl_x __ARGS((void));
static int has_compl_option __ARGS((int dict_opt));
+static int ins_compl_equal __ARGS((compl_T *match, char_u *str, int len));
static void ins_compl_longest_match __ARGS((compl_T *match));
-static void ins_compl_add_matches __ARGS((int num_matches, char_u **matches));
+static void ins_compl_add_matches __ARGS((int num_matches, char_u **matches, int icase));
static int ins_compl_make_cyclic __ARGS((void));
static void ins_compl_upd_pum __ARGS((void));
static void ins_compl_del_pum __ARGS((void));
@@ -144,6 +146,7 @@ static int ins_compl_next __ARGS((int allow_get_expansion, int count, int inser
static int ins_compl_key2dir __ARGS((int c));
static int ins_compl_pum_key __ARGS((int c));
static int ins_compl_key2count __ARGS((int c));
+static int ins_compl_use_match __ARGS((int c));
static int ins_complete __ARGS((int c));
static int quote_meta __ARGS((char_u *dest, char_u *str, int len));
#endif /* FEAT_INS_EXPAND */
@@ -1982,9 +1985,10 @@ vim_is_ctrl_x_key(c)
* TODO: make this work for multi-byte characters.
*/
int
-ins_compl_add_infercase(str, len, fname, dir, flags)
+ins_compl_add_infercase(str, len, icase, fname, dir, flags)
char_u *str;
int len;
+ int icase;
char_u *fname;
int dir;
int flags;
@@ -2038,26 +2042,22 @@ ins_compl_add_infercase(str, len, fname, dir, flags)
/* Copy the original case of the part we typed */
STRNCPY(IObuff, compl_orig_text, compl_length);
- return ins_compl_add(IObuff, len, fname, NULL, dir, flags);
+ return ins_compl_add(IObuff, len, icase, fname, NULL, dir, flags);
}
- return ins_compl_add(str, len, fname, NULL, dir, flags);
+ return ins_compl_add(str, len, icase, fname, NULL, dir, flags);
}
/*
* Add a match to the list of matches.
* If the given string is already in the list of completions, then return
- * FAIL, otherwise add it to the list and return OK. If there is an error,
- * maybe because alloc() returns NULL, then RET_ERROR is returned -- webb.
- *
- * New:
- * If the given string is already in the list of completions, then return
* NOTDONE, otherwise add it to the list and return OK. If there is an error,
- * maybe because alloc() returns NULL, then FAIL is returned -- webb.
+ * maybe because alloc() returns NULL, then FAIL is returned.
*/
int
-ins_compl_add(str, len, fname, extra, cdir, flags)
+ins_compl_add(str, len, icase, fname, extra, cdir, flags)
char_u *str;
int len;
+ int icase;
char_u *fname;
char_u *extra; /* extra text for popup menu or NULL */
int cdir;
@@ -2081,7 +2081,7 @@ ins_compl_add(str, len, fname, extra, cdir, flags)
do
{
if ( !(match->cp_flags & ORIGINAL_TEXT)
- && STRNCMP(match->cp_str, str, (size_t)len) == 0
+ && ins_compl_equal(match, str, len)
&& match->cp_str[len] == NUL)
return NOTDONE;
match = match->cp_next;
@@ -2109,6 +2109,7 @@ ins_compl_add(str, len, fname, extra, cdir, flags)
vim_free(match);
return FAIL;
}
+ match->cp_icase = icase;
/* match-fname is:
* - compl_curr_match->cp_fname if it is a string equal to fname.
@@ -2163,6 +2164,21 @@ ins_compl_add(str, len, fname, extra, cdir, flags)
}
/*
+ * Return TRUE if "str[len]" matches with match->cp_str, considering
+ * match->cp_icase.
+ */
+ static int
+ins_compl_equal(match, str, len)
+ compl_T *match;
+ char_u *str;
+ int len;
+{
+ if (match->cp_icase)
+ return STRNICMP(match->cp_str, str, (size_t)len) == 0;
+ return STRNCMP(match->cp_str, str, (size_t)len) == 0;
+}
+
+/*
* Reduce the longest common string for match "match".
*/
static void
@@ -2170,7 +2186,7 @@ ins_compl_longest_match(match)
compl_T *match;
{
char_u *p, *s;
- int l;
+ int c1, c2;
int had_match;
if (compl_leader == NULL)
@@ -2179,21 +2195,36 @@ ins_compl_longest_match(match)
else
{
/* Reduce the text if this match differs from compl_leader. */
- for (p = compl_leader, s = match->cp_str; *p != NUL; p += l, s += l)
+ p = compl_leader;
+ s = match->cp_str;
+ while (*p != NUL)
{
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- l = mb_ptr2len(p);
- if (STRNICMP(p, s, l) != 0)
- break;
+ c1 = mb_ptr2char(p);
+ c2 = mb_ptr2char(s);
}