Compare commits

...

41 Commits

Author SHA1 Message Date
Bram Moolenaar
059b7482a2 patch 8.0.0309: cannot use an empty key in json
Problem:    Cannot use an empty key in json.
Solution:   Allow for using an empty key.
2017-02-05 16:34:43 +01:00
Bram Moolenaar
2f9e575583 patch 8.0.0308: 'runtimepath' not update correctly when using symbolic link
Problem:    When using a symbolic link, the package path will not be inserted
            at the right position in 'runtimepath'. (Dugan Chen, Norio Takagi)
Solution:   Resolve symbolic links when finding the right position in
            'runtimepath'. (Hirohito Higashi)
2017-02-05 16:07:54 +01:00
Bram Moolenaar
955f198fc5 patch 8.0.0307: asan detects a memory error when EXITFREE is defined
Problem:    Asan detects a memory error when EXITFREE is defined. (Dominique
            Pelle)
Solution:   In getvcol() check for ml_get_buf() returning an empty string.
            Also skip adjusting the scroll position.  Set "exiting" in
            mch_exit() for all systems.
2017-02-05 15:10:51 +01:00
Bram Moolenaar
e971df39a5 patch 8.0.0306: mode() not sufficiently tested
Problem:    mode() not sufficiently tested.
Solution:   Add more tests. (Yegappan Lakshmanan)
2017-02-05 14:15:29 +01:00
Bram Moolenaar
aaaf57d8a9 patch 8.0.0305: invalid memory access when option has duplicate flag
Problem:    Invalid memory access when option has duplicate flag.
Solution:   Correct pointer computation. (Dominique Pelle, closes #1442)
2017-02-05 14:13:20 +01:00
Bram Moolenaar
1fb0d49803 patch 8.0.0304: assign test fails in the GUI
Problem:    Assign test fails in the GUI.
Solution:   Skip the test for setting t_k1.
2017-02-04 21:50:19 +01:00
Bram Moolenaar
a1891848d9 patch 8.0.0303: bracketed paste does not work in Visual mode
Problem:    Bracketed paste does not work in Visual mode.
Solution:   Delete the text before pasting
2017-02-04 21:34:31 +01:00
Bram Moolenaar
e353c402e6 patch 8.0.0302: cannot set terminal key codes with :let
Problem:    Cannot set terminal key codes with :let.
Solution:   Make it work.
2017-02-04 19:49:16 +01:00
Bram Moolenaar
698f8b207b patch 8.0.0301: not enough testing for setting options
Problem:    No tests for ":set completion" and various errors of the :set
            command.
Solution:   Add more :set tests. (Dominique Pelle, closes #1440)
2017-02-04 15:53:32 +01:00
Bram Moolenaar
25ea054458 patch 8.0.0300: cannot stop diffing hidden buffers
Problem:    Cannot stop diffing hidden buffers. (Daniel Hahler)
Solution:   When using :diffoff! make the whole list if diffed buffers empty.
            (closes #736)
2017-02-03 23:16:28 +01:00
Bram Moolenaar
6b40f30329 patch 8.0.0299: a window resize is sometimes not taking effect
Problem:    When the GUI window is resized Vim does not always take over the
            new size. (Luchr)
Solution:   Reset new_p_guifont in gui_resize_shell().  Call
            gui_may_resize_shell() in the main loop.
2017-02-03 22:01:47 +01:00
Bram Moolenaar
cbf20fbcd3 patch 8.0.0298: Ex command range with repeated search does not work
Problem:    Ex command range with repeated search does not work. (Bruce
            DeVisser)
Solution:   Skip over \/, \? and \&.
2017-02-03 21:19:04 +01:00
Bram Moolenaar
03ff9bcbc9 patch 8.0.0297: double free on exit when using a closure
Problem:    Double free on exit when using a closure. (James McCoy)
Solution:   Split free_al_functions in two parts. (closes #1428)
2017-02-02 22:59:27 +01:00
Bram Moolenaar
fd8983b09c patch 8.0.0296: bracketed paste can only append, not insert
Problem:    Bracketed paste can only append, not insert.
Solution:   When the cursor is in the first column insert the text.
2017-02-02 22:21:29 +01:00
Bram Moolenaar
7a073549a3 patch 8.0.0295: test_viml hangs
Problem:    test_viml hangs.
Solution:   Put resetting 'more' before sourcing the script.
2017-02-01 23:17:36 +01:00
Bram Moolenaar
79da563cf9 patch 8.0.0294: argument list is not stored correctly in a session file
Problem:    Argument list is not stored correctly in a session file.
            (lgpasquale)
Solution:   Use "$argadd" instead of "argadd". (closes #1434)
2017-02-01 22:52:44 +01:00
Bram Moolenaar
e5f2a075e3 patch 8.0.0293: some tests have a one or three second wait
Problem:    Some tests have a one or three second wait.
Solution:   Reset the 'showmode' option.  Use a test time of one to disable
            sleep after an error or warning message.
2017-02-01 22:31:49 +01:00
Bram Moolenaar
a2f28859bf patch 8.0.0292: the stat test is a bit slow
Problem:    The stat test is a bit slow.
Solution:   Remove a couple of sleep comments and reduce another.
2017-02-01 22:05:28 +01:00
Bram Moolenaar
23fa81d222 patch 8.0.0291: Visual block insertion does not insert in all lines
Problem:    Visual block insertion does not insert in all lines.
Solution:   Don't bail out of insert too early. Add a test. (Christian
            Brabandt, closes #1290)
2017-02-01 21:50:21 +01:00
Bram Moolenaar
04e87b72c5 patch 8.0.0290: cursor positioning wrong if wide character wraps
Problem:    If a wide character doesn't fit at the end of the screen line, and
            the line doesn't fit on the screen, then the cursor position may
            be wrong. (anliting)
Solution:   Don't skip over wide character. (Christian Brabandt, closes #1408)
2017-02-01 21:23:10 +01:00
Bram Moolenaar
21d7c9b601 patch 8.0.0289: no test for "ga" and :ascii
Problem:    No test for "ga" and :ascii.
Solution:   Add a test. (Dominique Pelle, closes #1429)
2017-02-01 20:53:38 +01:00
Bram Moolenaar
4e032e1b17 patch 8.0.0288: errors reported while running tests
Problem:    Errors reported while running tests.
Solution:   Put comma in the right place.
2017-02-01 20:48:13 +01:00
Bram Moolenaar
c7d9eacefa patch 8.0.0287: debug mode: cannot access function arguments
Problem:    Cannot access the arguments of the current function in debug mode.
            (Luc Hermitte)
Solution:   use get_funccal(). (Lemonboy, closes #1432, closes #1352)
2017-02-01 20:26:51 +01:00
Bram Moolenaar
c10f0e7cb0 patch 8.0.0286: not always redrawing after screen resize
Problem:    When concealing is active and the screen is resized in the GUI it
            is not immediately redrawn.
Solution:   Use update_prepare() and update_finish() from
            update_single_line().
2017-02-01 18:37:14 +01:00
Bram Moolenaar
c386267ffe patch 8.0.0285: tests fail with tiny build on Unix
Problem:    Tests fail with tiny build on Unix.
Solution:   Only set g:tester_HOME when build with the +eval feature.
2017-02-01 18:07:38 +01:00
Bram Moolenaar
b245559fa9 patch 8.0.0284: collapse buffers test failed once
Problem:    The Test_collapse_buffers() test failed once, looks like it is
            flaky.
Solution:   Add it to the list of flaky tests.
2017-02-01 18:00:13 +01:00
Bram Moolenaar
e90858d022 patch 8.0.0283: mode() does not indicate Insert mode completion
Problem:    The return value of mode() does not indicate that completion is
            active in Replace and Insert mode. (Zhen-Huan (Kenny) Hu)
Solution:   Add "c" or "x" for two kinds of completion. (Yegappan Lakshmanan,
            closes #1397)  Test some more modes.
2017-02-01 17:24:34 +01:00
Bram Moolenaar
0b5c93a7f2 patch 8.0.0282: need to use CTRL-O twice when in Visual-Insert mode
Problem:    When doing a Visual selection and using "I" to go to insert mode,
            CTRL-O needs to be used twice to go to Normal mode. (Coacher)
Solution:   Check for the return value of edit(). (Christian Brabandt,
            closes #1290)
2017-02-01 15:03:30 +01:00
Bram Moolenaar
1266d678bf patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Problem:    MS-Windows files are still using ARGSUSED while most other files
            have UNUSED.
Solution:   Change ARGSUSED to UNUSED or delete it.
2017-02-01 13:43:36 +01:00
Bram Moolenaar
7c23d1d9d9 patch 8.0.0280: problem setting multi-byte environment var on MS-Windows
Problem:    On MS-Windows setting an environment variable with multi-byte
            strings does not work well.
Solution:   Use wputenv when possible. (Taro Muraoka, Ken Takata)
2017-02-01 13:14:16 +01:00
Bram Moolenaar
168dd00f72 patch 8.0.0279: MSVC 2015 uses a different dll name
Problem:    With MSVC 2015 the dll name is vcruntime140.dll.
Solution:   Check the MSVC version and use the right dll name. (Ken Takata)
2017-02-01 13:02:47 +01:00
Bram Moolenaar
f1ab9c1370 patch 8.0.0278: GUI test fails on MS-Windows
Problem:    GUI test fails on MS-Windows.
Solution:   Check that tester_HOME exists.
2017-02-01 12:32:58 +01:00
Bram Moolenaar
56e6bd7ba2 patch 8.0.0277: the GUI test may trigger fontconfig and take a long time
Problem:    The GUI test may trigger fontconfig and take a long time.
Solution:   Set $XDG_CACHE_HOME. (Kazunobu Kuriyama)
2017-02-01 12:08:47 +01:00
Bram Moolenaar
3954e3c4b5 patch 8.0.0276: unnecessary #ifdefs
Problem:    Checking for FEAT_GUI_GNOME inside GTK 3 code is unnecessary.
Solution:   Remove the #ifdef. (Kazunobu Kuriyama)
2017-02-01 11:50:09 +01:00
Bram Moolenaar
e3caa11090 patch 8.0.0275: the screen may be updated at the wrong time
Problem:    When checking for CTRL-C typed the GUI may detect a screen resize
            and redraw the screen, causing trouble.
Solution:   Set updating_screen in ui_breakcheck().
2017-01-31 22:07:42 +01:00
Bram Moolenaar
070b33da93 patch 8.0.0274: possible recursive screen updating causes trouble
Problem:    When update_single_line() is called recursively, or another screen
            update happens while it is busy, errors may occur.
Solution:   Check and update updating_screen. (Christian Brabandt)
2017-01-31 21:53:39 +01:00
Bram Moolenaar
c4a249a736 patch 8.0.0273: dead code detected by Coverity
Problem:    Dead code detected by Coverity when not using gnome.
Solution:   Rearrange the #ifdefs to avoid dead code.
2017-01-30 22:56:48 +01:00
Bram Moolenaar
432c839ebd patch 8.0.0272: crash on exit is not detected when running tests
Problem:    Crash on exit is not detected when running tests.
Solution:   Remove the dash before the command. (Dominique Pelle, closes
            #1425)
2017-01-30 22:01:01 +01:00
Bram Moolenaar
a4c906a4a1 patch 8.0.0271: may get ml_get error when :tcldo deletes lines
Problem:    May get ml_get error when :tcldo deletes lines or switches to
            another buffer. (Nikolai Pavlov, closes #1421)
Solution:   Check the buffer and line every time.
2017-01-29 23:26:37 +01:00
Bram Moolenaar
c593fee0e5 patch 8.0.0270: may get ml_get error when :rubydo deletes lines
Problem:    May get ml_get error when :rubydo deletes lines or switches to
            another buffer. (Nikolai Pavlov, issue #1421)
Solution:   Check the buffer and line every time.
2017-01-29 23:11:25 +01:00
Bram Moolenaar
85b5743d3e patch 8.0.0269: may get ml_get error when :perldo deletes lines
Problem:    May get ml_get error when :perldo deletes lines or switches to
            another buffer. (Nikolai Pavlov, issue #1421)
Solution:   Check the buffer and line every time.
2017-01-29 22:59:12 +01:00
59 changed files with 1217 additions and 346 deletions

View File

@@ -5848,9 +5848,13 @@ mode([expr]) Return a string that indicates the current mode.
S Select by line
CTRL-S Select blockwise
i Insert
ic Insert mode completion |compl-generic|
ix Insert mode |i_CTRL-X| completion
R Replace |R|
Rc Replace mode completion |compl-generic|
Rv Virtual Replace |gR|
c Command-line
Rx Replace mode |i_CTRL-X| completion
c Command-line editing
cv Vim Ex mode |gQ|
ce Normal Ex mode |Q|
r Hit-enter prompt

View File

@@ -1,4 +1,4 @@
*term.txt* For Vim version 8.0. Last change: 2017 Jan 27
*term.txt* For Vim version 8.0. Last change: 2017 Feb 02
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -95,7 +95,12 @@ terminal when entering "raw" mode and 't_BD' when leaving "raw" mode. The
terminal is then expected to put 't_PS' before pasted text and 't_PE' after
pasted text. This way Vim can separate text that is pasted from characters
that are typed. The pasted text is handled like when the middle mouse button
is used.
is used, it is inserted literally and not interpreted as commands.
When the cursor is in the first column, the pasted text will be inserted
before it. Otherwise the pasted text is appended after the cursor position.
This means one cannot paste after the first column. Unfortunately Vim does
not have a way to tell where the mouse pointer was.
Note that in some situations Vim will not recognize the bracketed paste and
you will get the raw text. In other situations Vim will only get the first

View File

@@ -285,8 +285,10 @@ MSVCRT_VER = ($(MSVCVER) / 10 - 50)
# Base name of the msvcrXX.dll
!if $(MSVCRT_VER) <= 60
MSVCRT_NAME = msvcrt
!else
!elseif $(MSVCRT_VER) <= 130
MSVCRT_NAME = msvcr$(MSVCRT_VER)
!else
MSVCRT_NAME = vcruntime$(MSVCRT_VER)
!endif
!if $(MSVC_MAJOR) == 6

View File

@@ -2127,8 +2127,9 @@ test_arglist \
test_fnameescape \
test_fnamemodify \
test_fold \
test_glob2regpat \
test_ga \
test_gf \
test_glob2regpat \
test_gn \
test_goto \
test_gui \
@@ -2198,6 +2199,7 @@ test_arglist \
test_tabpage \
test_tagcase \
test_tagjump \
test_tcl \
test_textobjects \
test_timers \
test_true_false \

View File

@@ -1296,6 +1296,10 @@ getvcol(
posptr = NULL; /* continue until the NUL */
else
{
/* Special check for an empty line, which can happen on exit, when
* ml_get_buf() always returns an empty string. */
if (*ptr == NUL)
pos->col = 0;
posptr = ptr + pos->col;
#ifdef FEAT_MBYTE
if (has_mbyte)

View File

@@ -138,6 +138,23 @@ diff_buf_add(buf_T *buf)
EMSGN(_("E96: Cannot diff more than %ld buffers"), DB_COUNT);
}
/*
* Remove all buffers to make diffs for.
*/
static void
diff_buf_clear(void)
{
int i;
for (i = 0; i < DB_COUNT; ++i)
if (curtab->tp_diffbuf[i] != NULL)
{
curtab->tp_diffbuf[i] = NULL;
curtab->tp_diff_invalid = TRUE;
diff_redraw(TRUE);
}
}
/*
* Find buffer "buf" in the list of diff buffers for the current tab page.
* Return its index or DB_COUNT if not found.
@@ -1257,6 +1274,10 @@ ex_diffoff(exarg_T *eap)
#endif
}
/* Also remove hidden buffers from the list. */
if (eap->forceit)
diff_buf_clear();
#ifdef FEAT_SCROLLBIND
/* Remove "hor" from from 'scrollopt' if there are no diff windows left. */
if (!diffwin && vim_strchr(p_sbo, 'h') != NULL)

View File

@@ -7783,21 +7783,26 @@ f_mode(typval_T *argvars, typval_T *rettv)
}
else
#endif
if (State & REPLACE_FLAG)
buf[0] = 'R';
else
buf[0] = 'i';
{
if (State & REPLACE_FLAG)
buf[0] = 'R';
else
buf[0] = 'i';
#ifdef FEAT_INS_EXPAND
if (ins_compl_active())
buf[1] = 'c';
else if (ctrl_x_mode == 1)
buf[1] = 'x';
#endif
}
}
else if (State & CMDLINE)
else if ((State & CMDLINE) || exmode_active)
{
buf[0] = 'c';
if (exmode_active)
if (exmode_active == EXMODE_VIM)
buf[1] = 'v';
}
else if (exmode_active)
{
buf[0] = 'c';
buf[1] = 'e';
else if (exmode_active == EXMODE_NORMAL)
buf[1] = 'e';
}
else
{

View File

@@ -3509,6 +3509,9 @@ add_pack_plugin(char_u *fname, void *cookie)
size_t afterlen = 0;
char_u *ffname = fix_fname(fname);
size_t fname_len;
char_u *buf = NULL;
char_u *rtp_ffname;
int match;
if (ffname == NULL)
return;
@@ -3533,26 +3536,28 @@ add_pack_plugin(char_u *fname, void *cookie)
/* Find "ffname" in "p_rtp", ignoring '/' vs '\' differences. */
fname_len = STRLEN(ffname);
insp = p_rtp;
for (;;)
buf = alloc(MAXPATHL);
if (buf == NULL)
goto theend;
while (*insp != NUL)
{
if (vim_fnamencmp(insp, ffname, fname_len) == 0)
copy_option_part(&insp, buf, MAXPATHL, ",");
add_pathsep(buf);
rtp_ffname = fix_fname(buf);
if (rtp_ffname == NULL)
goto theend;
match = vim_fnamencmp(rtp_ffname, ffname, fname_len) == 0;
vim_free(rtp_ffname);
if (match)
break;
insp = vim_strchr(insp, ',');
if (insp == NULL)
break;
++insp;
}
if (insp == NULL)
if (*insp == NUL)
/* not found, append at the end */
insp = p_rtp + STRLEN(p_rtp);
else
{
/* append after the matching directory. */
insp += STRLEN(ffname);
while (*insp != NUL && *insp != ',')
++insp;
}
--insp;
*p4 = c;
/* check if rtp/pack/name/start/name/after exists */
@@ -3562,7 +3567,8 @@ add_pack_plugin(char_u *fname, void *cookie)
oldlen = STRLEN(p_rtp);
addlen = STRLEN(ffname) + 1; /* add one for comma */
new_rtp = alloc((int)(oldlen + addlen + afterlen + 1)); /* add one for NUL */
new_rtp = alloc((int)(oldlen + addlen + afterlen + 1));
/* add one for NUL */
if (new_rtp == NULL)
goto theend;
keep = (int)(insp - p_rtp);
@@ -3616,6 +3622,7 @@ add_pack_plugin(char_u *fname, void *cookie)
}
theend:
vim_free(buf);
vim_free(ffname);
}

View File

@@ -4357,9 +4357,16 @@ skip_range(
{
unsigned delim;
while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;", *cmd) != NULL)
while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;\\", *cmd) != NULL)
{
if (*cmd == '\'')
if (*cmd == '\\')
{
if (cmd[1] == '?' || cmd[1] == '/' || cmd[1] == '&')
++cmd;
else
break;
}
else if (*cmd == '\'')
{
if (*++cmd == NUL && ctx != NULL)
*ctx = EXPAND_NOTHING;
@@ -11790,7 +11797,7 @@ ses_arglist(
s = buf;
}
}
if (fputs("argadd ", fd) < 0
if (fputs("$argadd ", fd) < 0
|| ses_put_fname(fd, s, flagp) == FAIL
|| put_eol(fd) == FAIL)
{

View File

@@ -1459,6 +1459,8 @@ gui_resize_shell(int pixel_width, int pixel_height)
}
again:
new_pixel_width = 0;
new_pixel_height = 0;
busy = TRUE;
/* Flush pending output before redrawing */
@@ -1468,8 +1470,8 @@ again:
gui.num_rows = (pixel_height - gui_get_base_height()) / gui.char_height;
gui_position_components(pixel_width);
gui_reset_scroll_region();
/*
* At the "more" and ":confirm" prompt there is no redraw, put the cursor
* at the last line here (why does it have to be one row too low?).
@@ -1491,17 +1493,22 @@ again:
busy = FALSE;
/*
* We could have been called again while redrawing the screen.
* Need to do it all again with the latest size then.
*/
/* We may have been called again while redrawing the screen.
* Need to do it all again with the latest size then. But only if the size
* actually changed. */
if (new_pixel_height)
{
pixel_width = new_pixel_width;
pixel_height = new_pixel_height;
new_pixel_width = 0;
new_pixel_height = 0;
goto again;
if (pixel_width == new_pixel_width && pixel_height == new_pixel_height)
{
new_pixel_width = 0;
new_pixel_height = 0;
}
else
{
pixel_width = new_pixel_width;
pixel_height = new_pixel_height;
goto again;
}
}
}
@@ -1511,18 +1518,10 @@ again:
void
gui_may_resize_shell(void)
{
int h, w;
if (new_pixel_height)
{
/* careful: gui_resize_shell() may postpone the resize again if we
* were called indirectly by it */
w = new_pixel_width;
h = new_pixel_height;
new_pixel_width = 0;
new_pixel_height = 0;
gui_resize_shell(w, h);
}
gui_resize_shell(new_pixel_width, new_pixel_height);
}
int

View File

@@ -3171,9 +3171,9 @@ delete_event_cb(GtkWidget *widget UNUSED,
static int
get_item_dimensions(GtkWidget *widget, GtkOrientation orientation)
{
# ifdef FEAT_GUI_GNOME
GtkOrientation item_orientation = GTK_ORIENTATION_HORIZONTAL;
# ifdef FEAT_GUI_GNOME
if (using_gnome && widget != NULL)
{
GtkWidget *parent;
@@ -3192,7 +3192,10 @@ get_item_dimensions(GtkWidget *widget, GtkOrientation orientation)
item_orientation = bonobo_dock_item_get_orientation(dockitem);
}
}
# else
# define item_orientation GTK_ORIENTATION_HORIZONTAL
# endif
# if GTK_CHECK_VERSION(3,0,0)
if (widget != NULL
&& item_orientation == orientation
@@ -3209,16 +3212,16 @@ get_item_dimensions(GtkWidget *widget, GtkOrientation orientation)
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
return allocation.height;
else
return allocation.width;
return allocation.height;
# else
# ifdef FEAT_GUI_GNOME
if (orientation == GTK_ORIENTATION_HORIZONTAL)
return widget->allocation.height;
else
return widget->allocation.width;
# else
return widget->allocation.height;
# endif
# endif
}
return 0;

View File

@@ -558,13 +558,12 @@ gui_mch_set_blinking(long wait, long on, long off)
blink_offtime = off;
}
/* ARGSUSED */
static VOID CALLBACK
_OnBlinkTimer(
HWND hwnd,
UINT uMsg,
UINT uMsg UNUSED,
UINT idEvent,
DWORD dwTime)
DWORD dwTime UNUSED)
{
MSG msg;
@@ -590,7 +589,7 @@ _OnBlinkTimer(
gui_update_cursor(TRUE, FALSE);
blink_state = BLINK_ON;
blink_timer = (UINT) SetTimer(NULL, 0, (UINT)blink_ontime,
(TIMERPROC)_OnBlinkTimer);
(TIMERPROC)_OnBlinkTimer);
}
}
@@ -644,13 +643,12 @@ gui_mch_start_blink(void)
* Call-back routines.
*/
/*ARGSUSED*/
static VOID CALLBACK
_OnTimer(
HWND hwnd,
UINT uMsg,
UINT uMsg UNUSED,
UINT idEvent,
DWORD dwTime)
DWORD dwTime UNUSED)
{
MSG msg;
@@ -667,12 +665,11 @@ _OnTimer(
s_wait_timer = 0;
}
/*ARGSUSED*/
static void
_OnDeadChar(
HWND hwnd,
UINT ch,
int cRepeat)
HWND hwnd UNUSED,
UINT ch UNUSED,
int cRepeat UNUSED)
{
dead_key = 1;
}
@@ -752,12 +749,11 @@ char_to_string(int ch, char_u *string, int slen, int had_alt)
/*
* Key hit, add it to the input buffer.
*/
/*ARGSUSED*/
static void
_OnChar(
HWND hwnd,
HWND hwnd UNUSED,
UINT ch,
int cRepeat)
int cRepeat UNUSED)
{
char_u string[40];
int len = 0;
@@ -777,12 +773,11 @@ _OnChar(
/*
* Alt-Key hit, add it to the input buffer.
*/
/*ARGSUSED*/
static void
_OnSysChar(
HWND hwnd,
HWND hwnd UNUSED,
UINT cch,
int cRepeat)
int cRepeat UNUSED)
{
char_u string[40]; /* Enough for multibyte character */
int len;
@@ -861,11 +856,10 @@ _OnMouseEvent(
gui_send_mouse_event(button, x, y, repeated_click, vim_modifiers);
}
/*ARGSUSED*/
static void
_OnMouseButtonDown(
HWND hwnd,
BOOL fDoubleClick,
HWND hwnd UNUSED,
BOOL fDoubleClick UNUSED,
int x,
int y,
UINT keyFlags)
@@ -960,10 +954,9 @@ _OnMouseButtonDown(
}
}
/*ARGSUSED*/
static void
_OnMouseMoveOrRelease(
HWND hwnd,
HWND hwnd UNUSED,
int x,
int y,
UINT keyFlags)
@@ -1038,13 +1031,12 @@ gui_mswin_find_menu(
return pMenu;
}
/*ARGSUSED*/
static void
_OnMenu(
HWND hwnd,
HWND hwnd UNUSED,
int id,
HWND hwndCtl,
UINT codeNotify)
HWND hwndCtl UNUSED,
UINT codeNotify UNUSED)
{
vimmenu_T *pMenu;
@@ -1527,9 +1519,8 @@ gui_mch_get_font(
* Return the name of font "font" in allocated memory.
* Don't know how to get the actual name, thus use the provided name.
*/
/*ARGSUSED*/
char_u *
gui_mch_get_fontname(GuiFont font, char_u *name)
gui_mch_get_fontname(GuiFont font UNUSED, char_u *name)
{
if (name == NULL)
return NULL;
@@ -2175,13 +2166,12 @@ gui_mch_enable_menu(int flag)
#endif
}
/*ARGSUSED*/
void
gui_mch_set_menu_pos(
int x,
int y,
int w,
int h)
int x UNUSED,
int y UNUSED,
int w UNUSED,
int h UNUSED)
{
/* It will be in the right place anyway */
}
@@ -2817,10 +2807,8 @@ _OnEndSession(void)
* Get this message when the user clicks on the cross in the top right corner
* of a Windows95 window.
*/
/*ARGSUSED*/
static void
_OnClose(
HWND hwnd)
_OnClose(HWND hwnd UNUSED)
{
gui_shell_closed();
}
@@ -2829,8 +2817,7 @@ _OnClose(
* Get a message when the window is being destroyed.
*/
static void
_OnDestroy(
HWND hwnd)
_OnDestroy(HWND hwnd)
{
if (!destroying)
_OnClose(hwnd);
@@ -2883,11 +2870,10 @@ _OnPaint(
}
}
/*ARGSUSED*/
static void
_OnSize(
HWND hwnd,
UINT state,
UINT state UNUSED,
int cx,
int cy)
{
@@ -3124,9 +3110,8 @@ gui_mch_insert_lines(
}
/*ARGSUSED*/
void
gui_mch_exit(int rc)
gui_mch_exit(int rc UNUSED)
{
#if defined(FEAT_DIRECTX)
DWriteContext_Close(s_dwc);
@@ -3285,9 +3270,8 @@ gui_mch_wide_font_changed(void)
* Initialise vim to use the font with the given name.
* Return FAIL if the font could not be loaded, OK otherwise.
*/
/*ARGSUSED*/
int
gui_mch_init_font(char_u *font_name, int fontset)
gui_mch_init_font(char_u *font_name, int fontset UNUSED)
{
LOGFONT lf;
GuiFont font = NOFONT;
@@ -3416,11 +3400,10 @@ gui_mch_newfont(void)
/*
* Set the window title
*/
/*ARGSUSED*/
void
gui_mch_settitle(
char_u *title,
char_u *icon)
char_u *icon UNUSED)
{
set_window_title(s_hwnd, (title == NULL ? "VIM" : (char *)title));
}
@@ -3772,10 +3755,9 @@ gui_mch_browse(
}
#endif /* FEAT_BROWSE */
/*ARGSUSED*/
static void
_OnDropFiles(
HWND hwnd,
HWND hwnd UNUSED,
HDROP hDrop)
{
#ifdef FEAT_WINDOWS
@@ -3833,10 +3815,9 @@ _OnDropFiles(
#endif
}
/*ARGSUSED*/
static int
_OnScroll(
HWND hwnd,
HWND hwnd UNUSED,
HWND hwndCtl,
UINT code,
int pos)
@@ -3954,7 +3935,6 @@ _OnScroll(
* Return pointer to buffer in "tofree".
* Returns zero when out of memory.
*/
/*ARGSUSED*/
int
get_cmd_args(char *prog, char *cmdline, char ***argvp, char **tofree)
{
@@ -5588,10 +5568,14 @@ get_work_area(RECT *spi_rect)
/*
* Set the size of the window to the given width and height in pixels.
*/
/*ARGSUSED*/
void
gui_mch_set_shellsize(int width, int height,
int min_width, int min_height, int base_width, int base_height,
gui_mch_set_shellsize(
int width,
int height,
int min_width UNUSED,
int min_height UNUSED,
int base_width UNUSED,
int base_height UNUSED,
int direction)
{
RECT workarea_rect;
@@ -5752,9 +5736,8 @@ gui_mch_set_sp_color(guicolor_T color)
/*
* handle WM_IME_NOTIFY message
*/
/*ARGSUSED*/
static LRESULT
_OnImeNotify(HWND hWnd, DWORD dwCommand, DWORD dwData)
_OnImeNotify(HWND hWnd, DWORD dwCommand, DWORD dwData UNUSED)
{
LRESULT lResult = 0;
HIMC hImc;
@@ -5802,9 +5785,8 @@ _OnImeNotify(HWND hWnd, DWORD dwCommand, DWORD dwData)
return lResult;
}
/*ARGSUSED*/
static LRESULT
_OnImeComposition(HWND hwnd, WPARAM dbcs, LPARAM param)
_OnImeComposition(HWND hwnd, WPARAM dbcs UNUSED, LPARAM param)
{
char_u *ret;
int len;
@@ -6844,13 +6826,12 @@ gui_mch_menu_grey(
* pressed, return that button's ID - IDCANCEL (2), which is the button's
* number.
*/
/*ARGSUSED*/
static LRESULT CALLBACK
dialog_callback(
HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
LPARAM lParam UNUSED)
{
if (message == WM_INITDIALOG)
{
@@ -8536,13 +8517,12 @@ delete_tooltip(BalloonEval *beval)
PostMessage(beval->balloon, WM_CLOSE, 0, 0);
}
/*ARGSUSED*/
static VOID CALLBACK
BevalTimerProc(
HWND hwnd,
UINT uMsg,
UINT_PTR idEvent,
DWORD dwTime)
HWND hwnd UNUSED,
UINT uMsg UNUSED,
UINT_PTR idEvent UNUSED,
DWORD dwTime)
{
POINT pt;
RECT rect;
@@ -8578,16 +8558,14 @@ BevalTimerProc(
}
}
/*ARGSUSED*/
void
gui_mch_disable_beval_area(BalloonEval *beval)
gui_mch_disable_beval_area(BalloonEval *beval UNUSED)
{
// TRACE0("gui_mch_disable_beval_area {{{");
KillTimer(s_textArea, BevalTimerId);
// TRACE0("gui_mch_disable_beval_area }}}");
}
/*ARGSUSED*/
void
gui_mch_enable_beval_area(BalloonEval *beval)
{
@@ -8619,7 +8597,6 @@ gui_mch_post_balloon(BalloonEval *beval, char_u *mesg)
// TRACE0("gui_mch_post_balloon }}}");
}
/*ARGSUSED*/
BalloonEval *
gui_mch_create_beval_area(
void *target, /* ignored, always use s_textArea */
@@ -8659,9 +8636,8 @@ gui_mch_create_beval_area(
return beval;
}
/*ARGSUSED*/
static void
Handle_WM_Notify(HWND hwnd, LPNMHDR pnmh)
Handle_WM_Notify(HWND hwnd UNUSED, LPNMHDR pnmh)
{
if (pnmh->idFrom != ID_BEVAL_TOOLTIP) /* it is not our tooltip */
return;

View File

@@ -1286,6 +1286,7 @@ ex_perldo(exarg_T *eap)
SV *sv;
char *str;
linenr_T i;
buf_T *was_curbuf = curbuf;
if (bufempty())
return;
@@ -1321,11 +1322,14 @@ ex_perldo(exarg_T *eap)
SAVETMPS;
for (i = eap->line1; i <= eap->line2; i++)
{
/* Check the line number, the command my have deleted lines. */
if (i > curbuf->b_ml.ml_line_count)
break;
sv_setpv(GvSV(PL_defgv), (char *)ml_get(i));
PUSHMARK(sp);
perl_call_pv("VIM::perldo", G_SCALAR | G_EVAL);
str = SvPV(GvSV(PL_errgv), length);
if (length)
if (length || curbuf != was_curbuf)
break;
SPAGAIN;
if (SvTRUEx(POPs))

View File

@@ -783,6 +783,7 @@ void ex_rubydo(exarg_T *eap)
{
int state;
linenr_T i;
buf_T *was_curbuf = curbuf;
if (ensure_ruby_initialized())
{
@@ -792,6 +793,8 @@ void ex_rubydo(exarg_T *eap)
{
VALUE line;
if (i > curbuf->b_ml.ml_line_count)
break;
line = vim_str2rb_enc_str((char *)ml_get(i));
rb_lastline_set(line);
eval_enc_string_protect((char *) eap->arg, &state);
@@ -800,6 +803,8 @@ void ex_rubydo(exarg_T *eap)
error_print(state);
break;
}
if (was_curbuf != curbuf)
break;
line = rb_lastline_get();
if (!NIL_P(line))
{

View File

@@ -1958,6 +1958,7 @@ ex_tcldo(exarg_T *eap)
char var_line[VARNAME_SIZE];
linenr_T first_line = 0;
linenr_T last_line = 0;
buf_T *was_curbuf = curbuf;
rs = eap->line1;
re = eap->line2;
@@ -1979,6 +1980,8 @@ ex_tcldo(exarg_T *eap)
}
while (err == TCL_OK && rs <= re)
{
if ((linenr_T)rs > curbuf->b_ml.ml_line_count)
break;
line = (char *)ml_get_buf(curbuf, (linenr_T)rs, FALSE);
if (!line)
{
@@ -1994,7 +1997,7 @@ ex_tcldo(exarg_T *eap)
#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 5) || TCL_MAJOR_VERSION > 8
|| Tcl_LimitExceeded(tclinfo.interp)
#endif
)
|| curbuf != was_curbuf)
break;
line = (char *)Tcl_GetVar(tclinfo.interp, var_line, 0);
if (line)

View File

@@ -863,7 +863,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
&& cur_item != NULL)
{
top_item->jd_key = get_tv_string_buf_chk(cur_item, key_buf);
if (top_item->jd_key == NULL || *top_item->jd_key == NUL)
if (top_item->jd_key == NULL)
{
clear_tv(cur_item);
EMSG(_(e_invarg));

View File

@@ -1118,6 +1118,10 @@ main_loop(
skip_redraw = FALSE;
else if (do_redraw || stuff_empty())
{
# ifdef FEAT_GUI
/* If ui_breakcheck() was used a resize may have been postponed. */
gui_may_resize_shell();
# endif
#if defined(FEAT_AUTOCMD) || defined(FEAT_CONCEAL)
/* Trigger CursorMoved if the cursor moved. */
if (!finish_op && (

View File

@@ -3264,7 +3264,11 @@ change_warning(
#endif
msg_clr_eos();
(void)msg_end();
if (msg_silent == 0 && !silent_mode)
if (msg_silent == 0 && !silent_mode
#ifdef FEAT_EVAL
&& time_for_testing != 1
#endif
)
{
out_flush();
ui_delay(1000L, TRUE); /* give the user time to think about it */
@@ -4453,9 +4457,6 @@ vim_setenv(char_u *name, char_u *val)
{
sprintf((char *)envbuf, "%s=%s", name, val);
putenv((char *)envbuf);
# ifdef libintl_putenv
libintl_putenv((char *)envbuf);
# endif
}
#endif
#ifdef FEAT_GETTEXT

View File

@@ -2041,6 +2041,8 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
if (restart_edit == 0)
restart_edit = restart_edit_save;
else
cap->retval |= CA_COMMAND_BUSY;
}
#else
vim_beep(BO_OPER);
@@ -9048,6 +9050,34 @@ nv_edit(cmdarg_T *cap)
/* drop the pasted text */
bracketed_paste(PASTE_INSERT, TRUE, NULL);
}
else if (cap->cmdchar == K_PS && VIsual_active)
{
pos_T old_pos = curwin->w_cursor;
pos_T old_visual = VIsual;
/* In Visual mode the selected text is deleted. */
if (VIsual_mode == 'V' || curwin->w_cursor.lnum != VIsual.lnum)
{
shift_delete_registers();
cap->oap->regname = '1';
}
else
cap->oap->regname = '-';
cap->cmdchar = 'd';
cap->nchar = NUL;
nv_operator(cap);
do_pending_operator(cap, 0, FALSE);
cap->cmdchar = K_PS;
/* When the last char in the line was deleted then append. Detect this
* by checking if the cursor moved to before the Visual area. */
if (*ml_get_cursor() != NUL && lt(curwin->w_cursor, old_pos)
&& lt(curwin->w_cursor, old_visual))
inc_cursor();
/* Insert to replace the deleted text with the pasted text. */
invoke_edit(cap, FALSE, cap->cmdchar, FALSE);
}
else if (!checkclearopq(cap->oap))
{
switch (cap->cmdchar)
@@ -9077,8 +9107,14 @@ nv_edit(cmdarg_T *cap)
beginline(BL_WHITE|BL_FIX);
break;
case K_PS:
/* Bracketed paste works like "a"ppend, unless the cursor is in
* the first column, then it inserts. */
if (curwin->w_cursor.col == 0)
break;
/*FALLTHROUGH*/
case 'a': /* "a"ppend is like "i"nsert on the next character. */
case K_PS: /* bracketed paste works like "a"ppend */
#ifdef FEAT_VIRTUALEDIT
/* increment coladd when in virtual space, increment the
* column otherwise, also to append after an unprintable char */

View File

@@ -1627,6 +1627,22 @@ adjust_clip_reg(int *rp)
}
#endif
/*
* Shift the delete registers: "9 is cleared, "8 becomes "9, etc.
*/
void
shift_delete_registers()
{
int n;
y_current = &y_regs[9];
free_yank_all(); /* free register nine */
for (n = 9; n > 1; --n)
y_regs[n] = y_regs[n - 1];
y_previous = y_current = &y_regs[1];
y_regs[1].y_array = NULL; /* set register one to empty */
}
/*
* Handle a delete operation.
*
@@ -1739,12 +1755,7 @@ op_delete(oparg_T *oap)
if (orig_regname != 0 || oap->motion_type == MLINE
|| oap->line_count > 1 || oap->use_reg_one)
{
y_current = &y_regs[9];
free_yank_all(); /* free register nine */
for (n = 9; n > 1; --n)
y_regs[n] = y_regs[n - 1];
y_previous = y_current = &y_regs[1];
y_regs[1].y_array = NULL; /* set register one to empty */
shift_delete_registers();
if (op_yank(oap, TRUE, FALSE) == OK)
did_yank = TRUE;
}
@@ -2571,7 +2582,7 @@ op_insert(oparg_T *oap, long count1)
}
t1 = oap->start;
edit(NUL, FALSE, (linenr_T)count1);
(void)edit(NUL, FALSE, (linenr_T)count1);
/* When a tab was inserted, and the characters in front of the tab
* have been converted to a tab as well, the column of the cursor

View File

@@ -4954,7 +4954,7 @@ do_set(
if (flags & P_FLAGLIST)
{
/* Remove flags that appear twice. */
for (s = newval; *s; ++s)
for (s = newval; *s;)
{
/* if options have P_FLAGLIST and
* P_ONECOMMA such as 'whichwrap' */
@@ -4966,7 +4966,7 @@ do_set(
/* Remove the duplicated value and
* the next comma. */
STRMOVE(s, s + 2);
s -= 2;
continue;
}
}
else
@@ -4975,9 +4975,10 @@ do_set(
&& vim_strchr(s + 1, *s) != NULL)
{
STRMOVE(s, s + 1);
--s;
continue;
}
}
++s;
}
}
@@ -9197,7 +9198,35 @@ get_option_value(
opt_idx = findoption(name);
if (opt_idx < 0) /* unknown option */
{
int key;
if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
&& (key = find_key_option(name)) != 0)
{
char_u key_name[2];
char_u *p;
if (key < 0)
{
key_name[0] = KEY2TERMCAP0(key);
key_name[1] = KEY2TERMCAP1(key);
}
else
{
key_name[0] = KS_KEY;
key_name[1] = (key & 0xff);
}
p = find_termcode(key_name);
if (p != NULL)
{
if (stringval != NULL)
*stringval = vim_strsave(p);
return 0;
}
}
return -3;
}
varp = get_varp_scope(&(options[opt_idx]), opt_flags);
@@ -9455,7 +9484,33 @@ set_option_value(
opt_idx = findoption(name);
if (opt_idx < 0)
{
int key;
if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
&& (key = find_key_option(name)) != 0)
{
char_u key_name[2];
if (key < 0)
{
key_name[0] = KEY2TERMCAP0(key);
key_name[1] = KEY2TERMCAP1(key);
}
else
{
key_name[0] = KS_KEY;
key_name[1] = (key & 0xff);
}
add_termcode(key_name, string, FALSE);
if (full_screen)
ttest(FALSE);
redraw_all_later(CLEAR);
return NULL;
}
EMSG2(_("E355: Unknown option: %s"), name);
}
else
{
flags = options[opt_idx].flags;

View File

@@ -889,6 +889,8 @@ mch_early_init(void)
void
mch_exit(int r)
{
exiting = TRUE;
if (raw_in) /* put terminal in 'normal' mode */
{
settmode(TMODE_COOK);

View File

@@ -201,6 +201,8 @@ int _stricoll(char *a, char *b)
void
mch_exit(int r)
{
exiting = TRUE;
display_errors();
ml_close_all(TRUE); /* remove all memfiles */
@@ -306,10 +308,8 @@ mch_settitle(
* 2: Just restore icon (which we don't have)
* 3: Restore title and icon (which we don't have)
*/
/*ARGSUSED*/
void
mch_restore_title(
int which)
mch_restore_title(int which UNUSED)
{
#ifndef FEAT_GUI_MSWIN
SetConsoleTitle(g_szOrigTitle);
@@ -345,13 +345,12 @@ mch_can_restore_icon(void)
* When 'shellslash' set do it the other way around.
* Return OK or FAIL.
*/
/*ARGSUSED*/
int
mch_FullName(
char_u *fname,
char_u *buf,
int len,
int force)
int force UNUSED)
{
int nResult = FAIL;
@@ -636,9 +635,8 @@ vim_stat(const char *name, stat_T *stp)
}
#if defined(FEAT_GUI_MSWIN) || defined(PROTO)
/*ARGSUSED*/
void
mch_settmode(int tmode)
mch_settmode(int tmode UNUSED)
{
/* nothing to do */
}
@@ -817,10 +815,8 @@ mch_char_avail(void)
/*
* set screen mode, always fails.
*/
/*ARGSUSED*/
int
mch_screenmode(
char_u *arg)
mch_screenmode(char_u *arg UNUSED)
{
EMSG(_(e_screenmode));
return FAIL;
@@ -996,10 +992,8 @@ mch_libcall(
/*
* Debugging helper: expose the MCH_WRITE_DUMP stuff to other modules
*/
/*ARGSUSED*/
void
DumpPutS(
const char *psz)
DumpPutS(const char *psz UNUSED)
{
# ifdef MCH_WRITE_DUMP
if (fdDump)
@@ -1173,9 +1167,12 @@ swap_me(COLORREF colorref)
# define PDP_RETVAL INT_PTR
#endif
/*ARGSUSED*/
static PDP_RETVAL CALLBACK
PrintDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
PrintDlgProc(
HWND hDlg,
UINT message,
WPARAM wParam UNUSED,
LPARAM lParam UNUSED)
{
#ifdef FEAT_GETTEXT
NONCLIENTMETRICS nm;
@@ -1236,9 +1233,8 @@ PrintDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
return FALSE;
}
/*ARGSUSED*/
static BOOL CALLBACK
AbortProc(HDC hdcPrn, int iCode)
AbortProc(HDC hdcPrn UNUSED, int iCode UNUSED)
{
MSG msg;
@@ -1683,9 +1679,8 @@ mch_print_begin(prt_settings_T *psettings)
return (ret > 0);
}
/*ARGSUSED*/
void
mch_print_end(prt_settings_T *psettings)
mch_print_end(prt_settings_T *psettings UNUSED)
{
EndDoc(prt_dlg.hDC);
if (!*bUserAbort)
@@ -2764,12 +2759,11 @@ points_to_pixels(char_u *str, char_u **end, int vertical, long_i pprinter_dc)
return pixels;
}
/*ARGSUSED*/
static int CALLBACK
font_enumproc(
ENUMLOGFONT *elf,
NEWTEXTMETRIC *ntm,
int type,
NEWTEXTMETRIC *ntm UNUSED,
int type UNUSED,
LPARAM lparam)
{
/* Return value:

View File

@@ -38,13 +38,12 @@ void _cdecl SaveInst(HINSTANCE hInst);
static void (_cdecl *pSaveInst)(HINSTANCE);
#endif
/*ARGSUSED*/
int WINAPI
WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInst,
HINSTANCE hInstance UNUSED,
HINSTANCE hPrevInst UNUSED,
LPSTR lpszCmdLine,
int nCmdShow)
int nCmdShow UNUSED)
{
int argc = 0;
char **argv;

View File

@@ -515,6 +515,7 @@ static char *null_libintl_textdomain(const char *);
static char *null_libintl_bindtextdomain(const char *, const char *);
static char *null_libintl_bind_textdomain_codeset(const char *, const char *);
static int null_libintl_putenv(const char *);
static int null_libintl_wputenv(const wchar_t *);
static HINSTANCE hLibintlDLL = NULL;
char *(*dyn_libintl_gettext)(const char *) = null_libintl_gettext;
@@ -526,6 +527,7 @@ char *(*dyn_libintl_bindtextdomain)(const char *, const char *)
char *(*dyn_libintl_bind_textdomain_codeset)(const char *, const char *)
= null_libintl_bind_textdomain_codeset;
int (*dyn_libintl_putenv)(const char *) = null_libintl_putenv;
int (*dyn_libintl_wputenv)(const wchar_t *) = null_libintl_wputenv;
int
dyn_libintl_init(void)
@@ -591,9 +593,14 @@ dyn_libintl_init(void)
/* _putenv() function for the libintl.dll is optional. */
hmsvcrt = find_imported_module_by_funcname(hLibintlDLL, "getenv");
if (hmsvcrt != NULL)
{
dyn_libintl_putenv = (void *)GetProcAddress(hmsvcrt, "_putenv");
if (dyn_libintl_putenv == NULL || dyn_libintl_putenv == putenv)
dyn_libintl_wputenv = (void *)GetProcAddress(hmsvcrt, "_wputenv");
}
if (dyn_libintl_putenv == NULL || dyn_libintl_putenv == _putenv)
dyn_libintl_putenv = null_libintl_putenv;
if (dyn_libintl_wputenv == NULL || dyn_libintl_wputenv == _wputenv)
dyn_libintl_wputenv = null_libintl_wputenv;
return 1;
}
@@ -610,16 +617,15 @@ dyn_libintl_end(void)
dyn_libintl_bindtextdomain = null_libintl_bindtextdomain;
dyn_libintl_bind_textdomain_codeset = null_libintl_bind_textdomain_codeset;
dyn_libintl_putenv = null_libintl_putenv;
dyn_libintl_wputenv = null_libintl_wputenv;
}
/*ARGSUSED*/
static char *
null_libintl_gettext(const char *msgid)
{
return (char*)msgid;
}
/*ARGSUSED*/
static char *
null_libintl_ngettext(
const char *msgid,
@@ -629,31 +635,36 @@ null_libintl_ngettext(
return (char *)(n == 1 ? msgid : msgid_plural);
}
/*ARGSUSED*/
static char *
null_libintl_bindtextdomain(const char *domainname, const char *dirname)
null_libintl_bindtextdomain(
const char *domainname UNUSED,
const char *dirname UNUSED)
{
return NULL;
}
/*ARGSUSED*/
static char *
null_libintl_bind_textdomain_codeset(const char *domainname,
const char *codeset)
null_libintl_bind_textdomain_codeset(
const char *domainname UNUSED,
const char *codeset UNUSED)
{
return NULL;
}
/*ARGSUSED*/
static char *
null_libintl_textdomain(const char *domainname)
null_libintl_textdomain(const char *domainname UNUSED)
{
return NULL;
}
/*ARGSUSED*/
int
null_libintl_putenv(const char *envstring)
null_libintl_putenv(const char *envstring UNUSED)
{
return 0;
}
int
null_libintl_wputenv(const wchar_t *envstring UNUSED)
{
return 0;
}
@@ -1045,9 +1056,8 @@ decode_key_event(
* For the GUI the mouse handling is in gui_w32.c.
*/
# ifdef FEAT_GUI_W32
/*ARGSUSED*/
void
mch_setmouse(int on)
mch_setmouse(int on UNUSED)
{
}
# else
@@ -1643,13 +1653,12 @@ tgetch(int *pmodifiers, WCHAR *pch2)
* If time == -1, wait forever for characters.
* Returns the number of characters read into buf.
*/
/*ARGSUSED*/
int
mch_inchar(
char_u *buf,
int maxlen,
long time,
int tb_change_cnt)
char_u *buf UNUSED,
int maxlen UNUSED,
long time UNUSED,
int tb_change_cnt UNUSED)
{
#ifndef FEAT_GUI_W32 /* this isn't used for the GUI */
@@ -2529,8 +2538,9 @@ mch_init(void)
void
mch_exit(int r)
{
stoptermcap();
exiting = TRUE;
stoptermcap();
if (g_fWindInitCalled)
settmode(TMODE_COOK);
@@ -2577,11 +2587,10 @@ mch_exit(int r)
/*
* Do we have an interactive window?
*/
/*ARGSUSED*/
int
mch_check_win(
int argc,
char **argv)
int argc UNUSED,
char **argv UNUSED)
{
get_exe_name();
@@ -5333,11 +5342,10 @@ termcap_mode_end(void)
#ifdef FEAT_GUI_W32
/*ARGSUSED*/
void
mch_write(
char_u *s,
int len)
char_u *s UNUSED,
int len UNUSED)
{
/* never used */
}
@@ -6035,11 +6043,10 @@ mch_write(
/*
* Delay for "msec" milliseconds.
*/
/*ARGSUSED*/
void
mch_delay(
long msec,
int ignoreinput)
int ignoreinput UNUSED)
{
#ifdef FEAT_GUI_W32
Sleep((int)msec); /* never wait for input */
@@ -6128,9 +6135,8 @@ mch_breakcheck(int force)
/*
* How much main memory in KiB that can be used by VIM.
*/
/*ARGSUSED*/
long_u
mch_total_mem(int special)
mch_total_mem(int special UNUSED)
{
MEMORYSTATUSEX ms;
@@ -6985,3 +6991,43 @@ fix_arg_enc(void)
set_alist_count();
}
#endif
int
mch_setenv(char *var, char *value, int x)
{
char_u *envbuf;
envbuf = alloc((unsigned)(STRLEN(var) + STRLEN(value) + 2));
if (envbuf == NULL)
return -1;
sprintf((char *)envbuf, "%s=%s", var, value);
#ifdef FEAT_MBYTE
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
{
WCHAR *p = enc_to_utf16(envbuf, NULL);
vim_free(envbuf);
if (p == NULL)
return -1;
_wputenv(p);
# ifdef libintl_wputenv
libintl_wputenv(p);
# endif
/* Unlike Un*x systems, we can free the string for _wputenv(). */
vim_free(p);
}
else
#endif
{
_putenv((char *)envbuf);
# ifdef libintl_putenv
libintl_putenv((char *)envbuf);
# endif
/* Unlike Un*x systems, we can free the string for _putenv(). */
vim_free(envbuf);
}
return 0;
}

View File

@@ -202,7 +202,9 @@ Trace(char *pszFormat, ...);
#define ASSERT_NULL_OR_POINTER(p, type) \
ASSERT(((p) == NULL) || IsValidAddress((p), sizeof(type), FALSE))
#define mch_setenv(name, val, x) setenv(name, val, x)
#ifndef HAVE_SETENV
# define HAVE_SETENV
#endif
#define mch_getenv(x) (char_u *)getenv((char *)(x))
#ifdef __BORLANDC__
# define vim_mkdir(x, y) mkdir(x)

View File

@@ -23,6 +23,7 @@ int insert_reg(int regname, int literally);
int get_spec_reg(int regname, char_u **argp, int *allocated, int errmsg);
int cmdline_paste_reg(int regname, int literally, int remcr);
void adjust_clip_reg(int *rp);
void shift_delete_registers(void);
int op_delete(oparg_T *oap);
int op_replace(oparg_T *oap, int c);
void op_tilde(oparg_T *oap);

View File

@@ -65,4 +65,5 @@ void free_cmd_argsW(void);
void used_file_arg(char *name, int literal, int full_path, int diff_mode);
void set_alist_count(void);
void fix_arg_enc(void);
int mch_setenv(char *var, char *value, int x);
/* vim: set ft=c : */

View File

@@ -777,101 +777,7 @@ update_screen(int type)
#endif
}
#if defined(FEAT_CONCEAL) || defined(PROTO)
/*
* Return TRUE if the cursor line in window "wp" may be concealed, according
* to the 'concealcursor' option.
*/
int
conceal_cursor_line(win_T *wp)
{
int c;
if (*wp->w_p_cocu == NUL)
return FALSE;
if (get_real_state() & VISUAL)
c = 'v';
else if (State & INSERT)
c = 'i';
else if (State & NORMAL)
c = 'n';
else if (State & CMDLINE)
c = 'c';
else
return FALSE;
return vim_strchr(wp->w_p_cocu, c) != NULL;
}
/*
* Check if the cursor line needs to be redrawn because of 'concealcursor'.
*/
void
conceal_check_cursur_line(void)
{
if (curwin->w_p_cole > 0 && conceal_cursor_line(curwin))
{
need_cursor_line_redraw = TRUE;
/* Need to recompute cursor column, e.g., when starting Visual mode
* without concealing. */
curs_columns(TRUE);
}
}
void
update_single_line(win_T *wp, linenr_T lnum)
{
int row;
int j;
/* Don't do anything if the screen structures are (not yet) valid. */
if (!screen_valid(TRUE))
return;
if (lnum >= wp->w_topline && lnum < wp->w_botline
&& foldedCount(wp, lnum, &win_foldinfo) == 0)
{
# ifdef FEAT_GUI
/* Remove the cursor before starting to do anything, because scrolling
* may make it difficult to redraw the text under it. */
if (gui.in_use)
gui_undraw_cursor();
# endif
row = 0;
for (j = 0; j < wp->w_lines_valid; ++j)
{
if (lnum == wp->w_lines[j].wl_lnum)
{
screen_start(); /* not sure of screen cursor */
# ifdef FEAT_SEARCH_EXTRA
init_search_hl(wp);
start_search_hl();
prepare_search_hl(wp, lnum);
# endif
win_line(wp, lnum, row, row + wp->w_lines[j].wl_size, FALSE);
# if defined(FEAT_SEARCH_EXTRA)
end_search_hl();
# endif
break;
}
row += wp->w_lines[j].wl_size;
}
# ifdef FEAT_GUI
/* Redraw the cursor */
if (gui.in_use)
{
out_flush(); /* required before updating the cursor */
gui_update_cursor(FALSE, FALSE);
}
# endif
}
need_cursor_line_redraw = FALSE;
}
#endif
#if defined(FEAT_SIGNS) || defined(FEAT_GUI)
static void update_prepare(void);
static void update_finish(void);
#if defined(FEAT_SIGNS) || defined(FEAT_GUI) || defined(FEAT_CONCEAL)
/*
* Prepare for updating one or more windows.
* Caller must check for "updating_screen" already set to avoid recursiveness.
@@ -922,6 +828,87 @@ update_finish(void)
}
#endif
#if defined(FEAT_CONCEAL) || defined(PROTO)
/*
* Return TRUE if the cursor line in window "wp" may be concealed, according
* to the 'concealcursor' option.
*/
int
conceal_cursor_line(win_T *wp)
{
int c;
if (*wp->w_p_cocu == NUL)
return FALSE;
if (get_real_state() & VISUAL)
c = 'v';
else if (State & INSERT)
c = 'i';
else if (State & NORMAL)
c = 'n';
else if (State & CMDLINE)
c = 'c';
else
return FALSE;
return vim_strchr(wp->w_p_cocu, c) != NULL;
}
/*
* Check if the cursor line needs to be redrawn because of 'concealcursor'.
*/
void
conceal_check_cursur_line(void)
{
if (curwin->w_p_cole > 0 && conceal_cursor_line(curwin))
{
need_cursor_line_redraw = TRUE;
/* Need to recompute cursor column, e.g., when starting Visual mode
* without concealing. */
curs_columns(TRUE);
}
}
void
update_single_line(win_T *wp, linenr_T lnum)
{
int row;
int j;
/* Don't do anything if the screen structures are (not yet) valid. */
if (!screen_valid(TRUE) || updating_screen)
return;
if (lnum >= wp->w_topline && lnum < wp->w_botline
&& foldedCount(wp, lnum, &win_foldinfo) == 0)
{
update_prepare();
row = 0;
for (j = 0; j < wp->w_lines_valid; ++j)
{
if (lnum == wp->w_lines[j].wl_lnum)
{
screen_start(); /* not sure of screen cursor */
# ifdef FEAT_SEARCH_EXTRA
init_search_hl(wp);
start_search_hl();
prepare_search_hl(wp, lnum);
# endif
win_line(wp, lnum, row, row + wp->w_lines[j].wl_size, FALSE);
# if defined(FEAT_SEARCH_EXTRA)
end_search_hl();
# endif
break;
}
row += wp->w_lines[j].wl_size;
}
update_finish();
}
need_cursor_line_redraw = FALSE;
}
#endif
#if defined(FEAT_SIGNS) || defined(PROTO)
void
update_debug_sign(buf_T *buf, linenr_T lnum)
@@ -2916,7 +2903,7 @@ win_line(
int endrow,
int nochange UNUSED) /* not updating for changed text */
{
int col; /* visual column on screen */
int col = 0; /* visual column on screen */
unsigned off; /* offset in ScreenLines/ScreenAttrs */
int c = 0; /* init for GCC */
long vcol = 0; /* virtual column (for tabs) */
@@ -3442,7 +3429,11 @@ win_line(
#else
--ptr;
#endif
n_skip = v - vcol;
#ifdef FEAT_MBYTE
/* character fits on the screen, don't need to skip it */
if ((*mb_ptr2cells)(ptr) >= c && col == 0)
#endif
n_skip = v - vcol;
}
/*

View File

@@ -1337,6 +1337,7 @@ typedef struct
int uf_varargs; /* variable nr of arguments */
int uf_flags;
int uf_calls; /* nr of active calls */
int uf_cleared; /* func_clear() was already called */
garray_T uf_args; /* arguments */
garray_T uf_lines; /* function lines */
#ifdef FEAT_PROFILE

View File

@@ -193,6 +193,7 @@ NEW_TESTS = test_arglist.res \
test_substitute.res \
test_syntax.res \
test_system.res \
test_tcl.res \
test_textobjects.res \
test_undo.res \
test_usercommands.res \

View File

@@ -78,7 +78,7 @@ test1.out: test1.in
# 200 msec is sufficient, but only modern sleep supports a fraction of
# a second, fall back to a second if it fails.
@-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
-$(RUN_VIM) $*.in
$(RUN_VIM) $*.in
# For flaky tests retry one time. No tests at the moment.
#@/bin/sh -c "if test -f test.out -a $* = test61; then \
@@ -108,7 +108,7 @@ bench_re_freeze.out: bench_re_freeze.vim
# 200 msec is sufficient, but only modern sleep supports a fraction of
# a second, fall back to a second if it fails.
@-/bin/sh -c "sleep .2 > /dev/null 2>&1 || sleep 1"
-$(RUN_VIM) $*.in
$(RUN_VIM) $*.in
@/bin/sh -c "if test -f benchmark.out; then cat benchmark.out; fi"
nolog:

View File

@@ -88,6 +88,14 @@ endfunc
function RunTheTest(test)
echo 'Executing ' . a:test
" Avoid stopping at the "hit enter" prompt
set nomore
" Avoid a three second wait when a message is about to be overwritten by the
" mode message.
set noshowmode
if exists("*SetUp")
try
call SetUp()
@@ -153,16 +161,16 @@ endif
" Names of flaky tests.
let s:flaky = [
\ 'Test_reltime()',
\ 'Test_nb_basic()',
\ 'Test_communicate()',
\ 'Test_close_and_exit_cb()',
\ 'Test_collapse_buffers()',
\ 'Test_communicate()',
\ 'Test_nb_basic()',
\ 'Test_pipe_through_sort_all()',
\ 'Test_pipe_through_sort_some()'
\ 'Test_pipe_through_sort_some()',
\ 'Test_reltime()',
\ ]
" Locate Test_ functions and execute them.
set nomore
redir @q
silent function /^Test_
redir END

View File

@@ -19,6 +19,7 @@ source test_float_func.vim
source test_fnamemodify.vim
source test_functions.vim
source test_glob2regpat.vim
source test_ga.vim
source test_goto.vim
source test_help_tagjump.vim
source test_join.vim

View File

@@ -7,3 +7,25 @@ func Test_no_type_checking()
let v = 3.4
let v = 'hello'
endfunc
func Test_let_termcap()
" Terminal code
let old_t_te = &t_te
let &t_te = "\<Esc>[yes;"
call assert_match('t_te.*^[[yes;', execute("set termcap"))
let &t_te = old_t_te
if !has('gui_running')
" Key code
let old_t_k1 = &t_k1
let &t_k1 = "that"
call assert_match('t_k1.*that', execute("set termcap"))
let &t_k1 = old_t_k1
endif
call assert_fails('let x = &t_xx', 'E15')
let &t_xx = "yes"
call assert_equal("yes", &t_xx)
let &t_xx = ""
call assert_fails('let x = &t_xx', 'E15')
endfunc

View File

@@ -306,3 +306,28 @@ func Test_cmdline_complete_wildoptions()
call assert_equal(a, b)
bw!
endfunc
" using a leading backslash here
set cpo+=C
func Test_cmdline_search_range()
new
call setline(1, ['a', 'b', 'c', 'd'])
/d
1,\/s/b/B/
call assert_equal('B', getline(2))
/a
$
\?,4s/c/C/
call assert_equal('C', getline(3))
call setline(1, ['a', 'b', 'c', 'd'])
%s/c/c/
1,\&s/b/B/
call assert_equal('B', getline(2))
bwipe!
endfunc
set cpo&

View File

@@ -212,6 +212,7 @@ func Test_diffoff()
call setline(1, ['One', '', 'Two', 'Three'])
diffthis
redraw
call assert_notequal(normattr, screenattr(1, 1))
diffoff!
redraw
call assert_equal(normattr, screenattr(1, 1))
@@ -219,6 +220,42 @@ func Test_diffoff()
bwipe!
endfunc
func Test_diffoff_hidden()
set diffopt=filler,foldcolumn:0
e! one
call setline(1, ['Two', 'Three'])
let normattr = screenattr(1, 1)
diffthis
botright vert new two
call setline(1, ['One', 'Four'])
diffthis
redraw
call assert_notequal(normattr, screenattr(1, 1))
set hidden
close
redraw
" diffing with hidden buffer two
call assert_notequal(normattr, screenattr(1, 1))
diffoff
redraw
call assert_equal(normattr, screenattr(1, 1))
diffthis
redraw
" still diffing with hidden buffer two
call assert_notequal(normattr, screenattr(1, 1))
diffoff!
redraw
call assert_equal(normattr, screenattr(1, 1))
diffthis
redraw
" no longer diffing with hidden buffer two
call assert_equal(normattr, screenattr(1, 1))
bwipe!
bwipe!
set hidden& diffopt&
endfunc
func Test_setting_cursor()
new Xtest1
put =range(1,90)

View File

@@ -304,4 +304,123 @@ func Test_toupper()
call assert_equal("Ⱥ Ⱦ", toupper("ⱥ ⱦ"))
endfunc
" Tests for the mode() function
let current_modes = ''
func! Save_mode()
let g:current_modes = mode(0) . '-' . mode(1)
return ''
endfunc
func! Test_mode()
new
call append(0, ["Blue Ball Black", "Brown Band Bowl", ""])
inoremap <F2> <C-R>=Save_mode()<CR>
normal! 3G
exe "normal i\<F2>\<Esc>"
call assert_equal('i-i', g:current_modes)
" i_CTRL-P: Multiple matches
exe "normal i\<C-G>uBa\<C-P>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-P: Single match
exe "normal iBro\<C-P>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-X
exe "normal iBa\<C-X>\<F2>\<Esc>u"
call assert_equal('i-ix', g:current_modes)
" i_CTRL-X CTRL-P: Multiple matches
exe "normal iBa\<C-X>\<C-P>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-X CTRL-P: Single match
exe "normal iBro\<C-X>\<C-P>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-X CTRL-P + CTRL-P: Single match
exe "normal iBro\<C-X>\<C-P>\<C-P>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-X CTRL-L: Multiple matches
exe "normal i\<C-X>\<C-L>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-X CTRL-L: Single match
exe "normal iBlu\<C-X>\<C-L>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-P: No match
exe "normal iCom\<C-P>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-X CTRL-P: No match
exe "normal iCom\<C-X>\<C-P>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" i_CTRL-X CTRL-L: No match
exe "normal iabc\<C-X>\<C-L>\<F2>\<Esc>u"
call assert_equal('i-ic', g:current_modes)
" R_CTRL-P: Multiple matches
exe "normal RBa\<C-P>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-P: Single match
exe "normal RBro\<C-P>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-X
exe "normal RBa\<C-X>\<F2>\<Esc>u"
call assert_equal('R-Rx', g:current_modes)
" R_CTRL-X CTRL-P: Multiple matches
exe "normal RBa\<C-X>\<C-P>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-X CTRL-P: Single match
exe "normal RBro\<C-X>\<C-P>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-X CTRL-P + CTRL-P: Single match
exe "normal RBro\<C-X>\<C-P>\<C-P>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-X CTRL-L: Multiple matches
exe "normal R\<C-X>\<C-L>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-X CTRL-L: Single match
exe "normal RBlu\<C-X>\<C-L>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-P: No match
exe "normal RCom\<C-P>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-X CTRL-P: No match
exe "normal RCom\<C-X>\<C-P>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
" R_CTRL-X CTRL-L: No match
exe "normal Rabc\<C-X>\<C-L>\<F2>\<Esc>u"
call assert_equal('R-Rc', g:current_modes)
call assert_equal('n', mode(0))
call assert_equal('n', mode(1))
" How to test operator-pending mode?
call feedkeys("v", 'xt')
call assert_equal('v', mode())
call assert_equal('v', mode(1))
call feedkeys("\<Esc>V", 'xt')
call assert_equal('V', mode())
call assert_equal('V', mode(1))
call feedkeys("\<Esc>\<C-V>", 'xt')
call assert_equal("\<C-V>", mode())
call assert_equal("\<C-V>", mode(1))
call feedkeys("\<Esc>", 'xt')
call feedkeys("gh", 'xt')
call assert_equal('s', mode())
call assert_equal('s', mode(1))
call feedkeys("\<Esc>gH", 'xt')
call assert_equal('S', mode())
call assert_equal('S', mode(1))
call feedkeys("\<Esc>g\<C-H>", 'xt')
call assert_equal("\<C-S>", mode())
call assert_equal("\<C-S>", mode(1))
call feedkeys("\<Esc>", 'xt')
call feedkeys(":echo \<C-R>=Save_mode()\<C-U>\<CR>", 'xt')
call assert_equal('c-c', g:current_modes)
call feedkeys("gQecho \<C-R>=Save_mode()\<CR>\<CR>vi\<CR>", 'xt')
call assert_equal('c-cv', g:current_modes)
" How to test Ex mode?
bwipe!
iunmap <F2>
endfunc

37
src/testdir/test_ga.vim Normal file
View File

@@ -0,0 +1,37 @@
" Test ga normal command, and :ascii Ex command.
func Do_ga(c)
call setline(1, a:c)
let l:a = execute("norm 1goga")
let l:b = execute("ascii")
call assert_equal(l:a, l:b)
return l:a
endfunc
func Test_ga_command()
new
set display=uhex
call assert_equal("\nNUL", Do_ga(''))
call assert_equal("\n<<01>> 1, Hex 01, Octal 001", Do_ga("\x01"))
call assert_equal("\n<<09>> 9, Hex 09, Octal 011", Do_ga("\t"))
set display=
call assert_equal("\nNUL", Do_ga(''))
call assert_equal("\n<^A> 1, Hex 01, Octal 001", Do_ga("\x01"))
call assert_equal("\n<^I> 9, Hex 09, Octal 011", Do_ga("\t"))
call assert_equal("\n<e> 101, Hex 65, Octal 145", Do_ga('e'))
if !has('multi_byte')
return
endif
" Test a few multi-bytes characters.
call assert_equal("\n<é> 233, Hex 00e9, Octal 351", Do_ga('é'))
call assert_equal("\n<ẻ> 7867, Hex 1ebb, Octal 17273", Do_ga('ẻ'))
" Test with combining characters.
call assert_equal("\n<e> 101, Hex 65, Octal 145 < ́> 769, Hex 0301, Octal 1401", Do_ga("e\u0301"))
call assert_equal("\n<e> 101, Hex 65, Octal 145 < ́> 769, Hex 0301, Octal 1401 < ̱> 817, Hex 0331, Octal 1461", Do_ga("e\u0301\u0331"))
call assert_equal("\n<e> 101, Hex 65, Octal 145 < ́> 769, Hex 0301, Octal 1401 < ̱> 817, Hex 0331, Octal 1461 < ̸> 824, Hex 0338, Octal 1470", Do_ga("e\u0301\u0331\u0338"))
bwipe!
endfunc

View File

@@ -10,7 +10,12 @@ func SetUp()
set guifont=Courier\ 10\ Pitch/8/-1/5/50/0/0/0/0/0
endif
" Gnome insists on creating $HOME/.gnome2/..
" Gnome insists on creating $HOME/.gnome2/, set $HOME to avoid changing the
" actual home directory. But avoid triggering fontconfig by setting the
" cache directory. Only needed for Unix.
if $XDG_CACHE_HOME == '' && exists('g:tester_HOME')
let $XDG_CACHE_HOME = g:tester_HOME . '/.cache'
endif
call mkdir('Xhome')
let $HOME = fnamemodify('Xhome', ':p')
endfunc

View File

@@ -144,6 +144,11 @@ func Test_json_decode()
call assert_equal(type(v:none), type(json_decode('')))
call assert_equal("", json_decode('""'))
" empty key is OK
call assert_equal({'': 'ok'}, json_decode('{"": "ok"}'))
" but not twice
call assert_fails("call json_decode('{\"\": \"ok\", \"\": \"bad\"}')", 'E938:')
call assert_equal({'n': 1}, json_decode('{"n":1,}'))
call assert_fails("call json_decode(\"{'n':'1',}\")", 'E474:')
call assert_fails("call json_decode(\"'n'\")", 'E474:')

View File

@@ -110,6 +110,8 @@ func Test_map_langmap()
call feedkeys(":call append(line('$'), '+')\<CR>", "xt")
call assert_equal('+', getline('$'))
iunmap a
iunmap c
set nomodified
endfunc
@@ -120,7 +122,7 @@ func Test_map_feedkeys()
$-1
call feedkeys("0qqdw.ifoo\<Esc>qj0@q\<Esc>", "xt")
call assert_equal(['fooc d', 'fooc d'], getline(line('$') - 1, line('$')))
unmap .
nunmap .
set nomodified
endfunc

View File

@@ -110,4 +110,16 @@ func Test_mksession_winheight()
call delete('Xtest_mks.out')
endfunc
func Test_mksession_arglist()
argdel *
next file1 file2 file3 file4
mksession! Xtest_mks.out
source Xtest_mks.out
call assert_equal(['file1', 'file2', 'file3', 'file4'], argv())
call delete('Xtest_mks.out')
argdel *
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -2193,6 +2193,8 @@ func! Test_normal51_FileChangedRO()
if !has("autocmd")
return
endif
" Don't sleep after the warning message.
call test_settime(1)
call writefile(['foo'], 'Xreadonly.log')
new Xreadonly.log
setl ro
@@ -2202,6 +2204,7 @@ func! Test_normal51_FileChangedRO()
call assert_equal('Xreadonly.log', bufname(''))
" cleanup
call test_settime(0)
bw!
call delete("Xreadonly.log")
endfunc

View File

@@ -13,6 +13,12 @@ function! Test_whichwrap()
set whichwrap+=h,l
call assert_equal('b,s,h,l', &whichwrap)
set whichwrap=h,h
call assert_equal('h', &whichwrap)
set whichwrap=h,h,h
call assert_equal('h', &whichwrap)
set whichwrap&
endfunction
@@ -128,4 +134,95 @@ endfunc
func Test_thesaurus()
call Check_dir_option('thesaurus')
endfun
func Test_set_completion()
call feedkeys(":set di\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set dictionary diff diffexpr diffopt digraph directory display', @:)
" Expand boolan options. When doing :set no<Tab>
" vim displays the options names without "no" but completion uses "no...".
call feedkeys(":set nodi\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set nodiff digraph', @:)
call feedkeys(":set invdi\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set invdiff digraph', @:)
" Expand abbreviation of options.
call feedkeys(":set ts\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set tabstop thesaurus ttyscroll', @:)
" Expand current value
call feedkeys(":set fileencodings=\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set fileencodings=ucs-bom,utf-8,default,latin1', @:)
call feedkeys(":set fileencodings:\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set fileencodings:ucs-bom,utf-8,default,latin1', @:)
" Expand key codes.
call feedkeys(":set <H\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set <Help> <Home>', @:)
" Expand terminal options.
call feedkeys(":set t_A\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set t_AB t_AF t_AL', @:)
" Expand directories.
call feedkeys(":set cdpath=./\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_match(' ./samples/ ', @:)
call assert_notmatch(' ./small.vim ', @:)
" Expand files and directories.
call feedkeys(":set tags=./\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_match(' ./samples/.* ./small.vim', @:)
call feedkeys(":set tags=./\\\\ dif\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:)
endfunc
func Test_set_errors()
call assert_fails('set scroll=-1', 'E49:')
call assert_fails('set backupcopy=', 'E474:')
call assert_fails('set regexpengine=3', 'E474:')
call assert_fails('set history=10001', 'E474:')
call assert_fails('set numberwidth=11', 'E474:')
call assert_fails('set colorcolumn=-a')
call assert_fails('set colorcolumn=a')
call assert_fails('set colorcolumn=1,')
call assert_fails('set cmdheight=-1', 'E487:')
call assert_fails('set cmdwinheight=-1', 'E487:')
if has('conceal')
call assert_fails('set conceallevel=-1', 'E487:')
call assert_fails('set conceallevel=4', 'E474:')
endif
call assert_fails('set helpheight=-1', 'E487:')
call assert_fails('set history=-1', 'E487:')
call assert_fails('set report=-1', 'E487:')
call assert_fails('set shiftwidth=-1', 'E487:')
call assert_fails('set sidescroll=-1', 'E487:')
call assert_fails('set tabstop=-1', 'E487:')
call assert_fails('set textwidth=-1', 'E487:')
call assert_fails('set timeoutlen=-1', 'E487:')
call assert_fails('set updatecount=-1', 'E487:')
call assert_fails('set updatetime=-1', 'E487:')
call assert_fails('set winheight=-1', 'E487:')
call assert_fails('set tabstop!', 'E488:')
call assert_fails('set xxx', 'E518:')
call assert_fails('set beautify?', 'E519:')
call assert_fails('set undolevels=x', 'E521:')
call assert_fails('set tabstop=', 'E521:')
call assert_fails('set comments=-', 'E524:')
call assert_fails('set comments=a', 'E525:')
call assert_fails('set foldmarker=x', 'E536:')
call assert_fails('set commentstring=x', 'E537:')
call assert_fails('set complete=x', 'E539:')
call assert_fails('set statusline=%{', 'E540:')
call assert_fails('set statusline=' . repeat("%p", 81), 'E541:')
call assert_fails('set statusline=%(', 'E542:')
call assert_fails('set guicursor=x', 'E545:')
call assert_fails('set backupext=~ patchmode=~', 'E589:')
call assert_fails('set winminheight=10 winheight=9', 'E591:')
call assert_fails('set winminwidth=10 winwidth=9', 'E592:')
call assert_fails("set showbreak=\x01", 'E595:')
call assert_fails('set t_foo=', 'E846:')
endfunc

View File

@@ -67,6 +67,39 @@ func Test_packadd_noload()
call assert_equal(new_rtp, &rtp)
endfunc
func Test_packadd_symlink_dir()
if !has('unix')
return
endif
let top2_dir = s:topdir . '/Xdir2'
let real_dir = s:topdir . '/Xsym'
silent !ln -s real_dir top2_dir
let &rtp = top2_dir . ',' . top2_dir . '/after'
let &packpath = &rtp
let s:plugdir = top2_dir . '/pack/mine/opt/mytest'
call mkdir(s:plugdir . '/plugin', 'p')
exe 'split ' . s:plugdir . '/plugin/test.vim'
call setline(1, 'let g:plugin_works = 44')
wq
let g:plugin_works = 0
packadd mytest
" Must have been inserted in the middle, not at the end
call assert_true(&rtp =~ '/pack/mine/opt/mytest,')
call assert_equal(44, g:plugin_works)
" No change when doing it again.
let rtp_before = &rtp
packadd mytest
call assert_equal(rtp_before, &rtp)
set rtp&
let rtp = &rtp
endfunc
" Check command-line completion for 'packadd'
func Test_packadd_completion()
let optdir1 = &packpath . '/pack/mine/opt'

View File

@@ -8,18 +8,36 @@ set term=xterm
func Test_paste_normal_mode()
new
" In first column text is inserted
call setline(1, ['a', 'b', 'c'])
2
call cursor(2, 1)
call feedkeys("\<Esc>[200~foo\<CR>bar\<Esc>[201~", 'xt')
call assert_equal('bfoo', getline(2))
call assert_equal('bar', getline(3))
call assert_equal('foo', getline(2))
call assert_equal('barb', getline(3))
call assert_equal('c', getline(4))
" When repeating text is appended
normal .
call assert_equal('barfoo', getline(3))
call assert_equal('bar', getline(4))
call assert_equal('barb', getline(4))
call assert_equal('c', getline(5))
bwipe!
" In second column text is appended
call setline(1, ['a', 'bbb', 'c'])
call cursor(2, 2)
call feedkeys("\<Esc>[200~foo\<CR>bar\<Esc>[201~", 'xt')
call assert_equal('bbfoo', getline(2))
call assert_equal('barb', getline(3))
call assert_equal('c', getline(4))
" In last column text is appended
call setline(1, ['a', 'bbb', 'c'])
call cursor(2, 3)
call feedkeys("\<Esc>[200~foo\<CR>bar\<Esc>[201~", 'xt')
call assert_equal('bbbfoo', getline(2))
call assert_equal('bar', getline(3))
call assert_equal('c', getline(4))
endfunc
func Test_paste_insert_mode()
@@ -52,3 +70,30 @@ func Test_paste_cmdline()
call feedkeys(":a\<Esc>[200~foo\<CR>bar\<Esc>[201~b\<Home>\"\<CR>", 'xt')
call assert_equal("\"afoo\<CR>barb", getreg(':'))
endfunc
func Test_paste_visual_mode()
new
call setline(1, 'here are some words')
call feedkeys("0fsve\<Esc>[200~more\<Esc>[201~", 'xt')
call assert_equal('here are more words', getline(1))
call assert_equal('some', getreg('-'))
" include last char in the line
call feedkeys("0fwve\<Esc>[200~noises\<Esc>[201~", 'xt')
call assert_equal('here are more noises', getline(1))
call assert_equal('words', getreg('-'))
" exclude last char in the line
call setline(1, 'some words!')
call feedkeys("0fwve\<Esc>[200~noises\<Esc>[201~", 'xt')
call assert_equal('some noises!', getline(1))
call assert_equal('words', getreg('-'))
" multi-line selection
call setline(1, ['some words', 'and more'])
call feedkeys("0fwvj0fd\<Esc>[200~letters\<Esc>[201~", 'xt')
call assert_equal('some letters more', getline(1))
call assert_equal("words\nand", getreg('1'))
bwipe!
endfunc

View File

@@ -82,6 +82,21 @@ function Test_perldo()
1
call assert_false(search('\Cperl'))
bw!
" Check deleting lines does not trigger ml_get error.
new
call setline(1, ['one', 'two', 'three'])
perldo VIM::DoCommand("%d_")
bwipe!
" Check switching to another buffer does not trigger ml_get error.
new
let wincount = winnr('$')
call setline(1, ['one', 'two', 'three'])
perldo VIM::DoCommand("new")
call assert_equal(wincount + 1, winnr('$'))
bwipe!
bwipe!
endfunc
function Test_VIM_package()

View File

@@ -32,3 +32,20 @@ func Test_ruby_evaluate_dict()
redir END
call assert_equal(['{"a"=>"foo", "b"=>123}'], split(l:out, "\n"))
endfunc
func Test_rubydo()
" Check deleting lines does not trigger ml_get error.
new
call setline(1, ['one', 'two', 'three'])
rubydo Vim.command("%d_")
bwipe!
" Check switching to another buffer does not trigger ml_get error.
new
let wincount = winnr('$')
call setline(1, ['one', 'two', 'three'])
rubydo Vim.command("new")
call assert_equal(wincount + 1, winnr('$'))
bwipe!
bwipe!
endfunc

View File

@@ -1,24 +1,24 @@
" Tests for stat functions and checktime
func Test_existent_file()
let fname='Xtest.tmp'
let fname = 'Xtest.tmp'
let ts=localtime()
sleep 1
let fl=['Hello World!']
let ts = localtime()
let fl = ['Hello World!']
call writefile(fl, fname)
let tf=getftime(fname)
sleep 1
let te=localtime()
let tf = getftime(fname)
let te = localtime()
call assert_true(ts <= tf && tf <= te)
call assert_equal(strlen(fl[0] . "\n"), getfsize(fname))
call assert_equal('file', getftype(fname))
call assert_equal('rw-', getfperm(fname)[0:2])
call delete(fname)
endfunc
func Test_existent_directory()
let dname='.'
let dname = '.'
call assert_equal(0, getfsize(dname))
call assert_equal('dir', getftype(dname))
@@ -26,22 +26,29 @@ func Test_existent_directory()
endfunc
func Test_checktime()
let fname='Xtest.tmp'
let fname = 'Xtest.tmp'
let fl=['Hello World!']
let fl = ['Hello World!']
call writefile(fl, fname)
set autoread
exec 'e' fname
sleep 2
let fl=readfile(fname)
" FAT has a granularity of 2 seconds, otherwise it's usually 1 second
if has('win32')
sleep 2
else
sleep 1
endif
let fl = readfile(fname)
let fl[0] .= ' - checktime'
call writefile(fl, fname)
checktime
call assert_equal(fl[0], getline(1))
call delete(fname)
endfunc
func Test_nonexistent_file()
let fname='Xtest.tmp'
let fname = 'Xtest.tmp'
call delete(fname)
call assert_equal(-1, getftime(fname))
@@ -55,7 +62,7 @@ func Test_win32_symlink_dir()
" So we use an existing symlink for this test.
if has('win32')
" Check if 'C:\Users\All Users' is a symlink to a directory.
let res=system('dir C:\Users /a')
let res = system('dir C:\Users /a')
if match(res, '\C<SYMLINKD> *All Users') >= 0
" Get the filetype of the symlink.
call assert_equal('dir', getftype('C:\Users\All Users'))

23
src/testdir/test_tcl.vim Normal file
View File

@@ -0,0 +1,23 @@
" Tests for the Tcl interface.
if !has('tcl')
finish
end
function Test_tcldo()
" Check deleting lines does not trigger ml_get error.
new
call setline(1, ['one', 'two', 'three'])
tcldo ::vim::command %d_
bwipe!
" Check switching to another buffer does not trigger ml_get error.
new
let wincount = winnr('$')
call setline(1, ['one', 'two', 'three'])
tcldo ::vim::command new
call assert_equal(wincount + 1, winnr('$'))
bwipe!
bwipe!
endfunc

View File

@@ -23,3 +23,16 @@ func Test_dotregister_paste()
call assert_equal('hello world world', getline(1))
q!
endfunc
func Test_Visual_ctrl_o()
new
call setline(1, ['one', 'two', 'three'])
call cursor(1,2)
set noshowmode
set tw=0
call feedkeys("\<c-v>jjlIa\<c-\>\<c-o>:set tw=88\<cr>\<esc>", 'tx')
call assert_equal(['oane', 'tawo', 'tahree'], getline(1, 3))
call assert_equal(88, &tw)
set tw&
bw!
endfu

View File

@@ -2,4 +2,12 @@
" Always use "sh", don't use the value of "$SHELL".
set shell=sh
" Only when the +eval feature is present.
if 1
" While some tests overwrite $HOME to prevent them from polluting user files,
" we need to remember the original value so that we can tell external systems
" where to ask about their own user settings.
let g:tester_HOME = $HOME
endif
source setup.vim

View File

@@ -363,12 +363,19 @@ ui_breakcheck(void)
void
ui_breakcheck_force(int force)
{
int save_us = updating_screen;
/* We do not want gui_resize_shell() to redraw the screen here. */
++updating_screen;
#ifdef FEAT_GUI
if (gui.in_use)
gui_mch_update();
else
#endif
mch_breakcheck(force);
updating_screen = save_us;
}
/*****************************************************************************

View File

@@ -1075,12 +1075,17 @@ func_remove(ufunc_T *fp)
}
/*
* Free a function and remove it from the list of functions.
* Free all things that a function contains. Does not free the function
* itself, use func_free() for that.
* When "force" is TRUE we are exiting.
*/
static void
func_free(ufunc_T *fp, int force)
func_clear(ufunc_T *fp, int force)
{
if (fp->uf_cleared)
return;
fp->uf_cleared = TRUE;
/* clear this function */
ga_clear_strings(&(fp->uf_args));
ga_clear_strings(&(fp->uf_lines));
@@ -1089,16 +1094,35 @@ func_free(ufunc_T *fp, int force)
vim_free(fp->uf_tml_total);
vim_free(fp->uf_tml_self);
#endif
funccal_unref(fp->uf_scoped, fp, force);
}
/*
* Free a function and remove it from the list of functions. Does not free
* what a function contains, call func_clear() first.
*/
static void
func_free(ufunc_T *fp)
{
/* only remove it when not done already, otherwise we would remove a newer
* version of the function */
if ((fp->uf_flags & (FC_DELETED | FC_REMOVED)) == 0)
func_remove(fp);
funccal_unref(fp->uf_scoped, fp, force);
vim_free(fp);
}
/*
* Free all things that a function contains and free the function itself.
* When "force" is TRUE we are exiting.
*/
static void
func_clear_free(ufunc_T *fp, int force)
{
func_clear(fp, force);
func_free(fp);
}
/*
* There are two kinds of function names:
* 1. ordinary names, function defined with :function
@@ -1120,10 +1144,40 @@ free_all_functions(void)
hashitem_T *hi;
ufunc_T *fp;
long_u skipped = 0;
long_u todo;
long_u todo = 1;
long_u used;
/* Need to start all over every time, because func_free() may change the
* hash table. */
/* First clear what the functions contain. Since this may lower the
* reference count of a function, it may also free a function and change
* the hash table. Restart if that happens. */
while (todo > 0)
{
todo = func_hashtab.ht_used;
for (hi = func_hashtab.ht_array; todo > 0; ++hi)
if (!HASHITEM_EMPTY(hi))
{
/* Only free functions that are not refcounted, those are
* supposed to be freed when no longer referenced. */
fp = HI2UF(hi);
if (func_name_refcount(fp->uf_name))
++skipped;
else
{
used = func_hashtab.ht_used;
func_clear(fp, TRUE);
if (used != func_hashtab.ht_used)
{
skipped = 0;
break;
}
}
--todo;
}
}
/* Now actually free the functions. Need to start all over every time,
* because func_free() may change the hash table. */
skipped = 0;
while (func_hashtab.ht_used > skipped)
{
todo = func_hashtab.ht_used;
@@ -1138,7 +1192,7 @@ free_all_functions(void)
++skipped;
else
{
func_free(fp, TRUE);
func_free(fp);
skipped = 0;
break;
}
@@ -1356,7 +1410,7 @@ call_func(
if (--fp->uf_calls <= 0 && fp->uf_refcount <= 0)
/* Function was unreferenced while being used, free it
* now. */
func_free(fp, FALSE);
func_clear_free(fp, FALSE);
if (did_save_redo)
restoreRedobuff();
restore_search_patterns();
@@ -2756,7 +2810,7 @@ ex_delfunction(exarg_T *eap)
fp->uf_flags |= FC_DELETED;
}
else
func_free(fp, FALSE);
func_clear_free(fp, FALSE);
}
}
}
@@ -2785,7 +2839,7 @@ func_unref(char_u *name)
/* Only delete it when it's not being used. Otherwise it's done
* when "uf_calls" becomes zero. */
if (fp->uf_calls == 0)
func_free(fp, FALSE);
func_clear_free(fp, FALSE);
}
}
@@ -2801,7 +2855,7 @@ func_ptr_unref(ufunc_T *fp)
/* Only delete it when it's not being used. Otherwise it's done
* when "uf_calls" becomes zero. */
if (fp->uf_calls == 0)
func_free(fp, FALSE);
func_clear_free(fp, FALSE);
}
}
@@ -3556,7 +3610,7 @@ get_funccal_args_var()
{
if (current_funccal == NULL)
return NULL;
return &current_funccal->l_avars_var;
return &get_funccal()->l_avars_var;
}
/*

View File

@@ -764,6 +764,88 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
309,
/**/
308,
/**/
307,
/**/
306,
/**/
305,
/**/
304,
/**/
303,
/**/
302,
/**/
301,
/**/
300,
/**/
299,
/**/
298,
/**/
297,
/**/
296,
/**/
295,
/**/
294,
/**/
293,
/**/
292,
/**/
291,
/**/
290,
/**/
289,
/**/
288,
/**/
287,
/**/
286,
/**/
285,
/**/
284,
/**/
283,
/**/
282,
/**/
281,
/**/
280,
/**/
279,
/**/
278,
/**/
277,
/**/
276,
/**/
275,
/**/
274,
/**/
273,
/**/
272,
/**/
271,
/**/
270,
/**/
269,
/**/
268,
/**/

View File

@@ -594,6 +594,7 @@ extern int (*dyn_libintl_putenv)(const char *envstring);
# endif
# define textdomain(domain) (*dyn_libintl_textdomain)(domain)
# define libintl_putenv(envstring) (*dyn_libintl_putenv)(envstring)
# define libintl_wputenv(envstring) (*dyn_libintl_wputenv)(envstring)
# else
# include <libintl.h>
# define _(x) gettext((char *)(x))

View File

@@ -10,7 +10,7 @@
/*
* winclip.c
*
* Routines common to both Win16 and Win32 for clipboard handling.
* Routines for Win32 clipboard handling.
* Also used by Cygwin, using os_unix.c.
*/
@@ -214,9 +214,8 @@ typedef struct
/*
* Make vim the owner of the current selection. Return OK upon success.
*/
/*ARGSUSED*/
int
clip_mch_own_selection(VimClipboard *cbd)
clip_mch_own_selection(VimClipboard *cbd UNUSED)
{
/*
* Never actually own the clipboard. If another application sets the
@@ -228,9 +227,8 @@ clip_mch_own_selection(VimClipboard *cbd)
/*
* Make vim NOT the owner of the current selection.
*/
/*ARGSUSED*/
void
clip_mch_lose_selection(VimClipboard *cbd)
clip_mch_lose_selection(VimClipboard *cbd UNUSED)
{
/* Nothing needs to be done here */
}

View File

@@ -5708,7 +5708,10 @@ win_new_height(win_T *wp, int height)
wp->w_height = height;
wp->w_skipcol = 0;
scroll_to_fraction(wp, prev_height);
/* There is no point in adjusting the scroll position when exiting. Some
* values might be invalid. */
if (!exiting)
scroll_to_fraction(wp, prev_height);
}
void