Merge remote-tracking branch 'vim/master'

This commit is contained in:
ichizok
2022-08-30 13:52:39 +09:00
60 changed files with 939 additions and 766 deletions
+10
View File
@@ -3833,6 +3833,16 @@ text...
:echomsg "It's a Zizzer Zazzer Zuzz, as you can plainly see."
< See |:echo-redraw| to avoid the message disappearing
when the screen is redrawn.
*:echow* *:echowin* *:echowindow*
:echow[indow] {expr1} ..
Like |:echomsg| but when the messages popup window is
available the message is displayed there. This means
it will show for three seconds and avoid a
|hit-enter| prompt.
The message window is available when Vim was compiled
with the +timer and the +popupwin features.
*:echoe* *:echoerr*
:echoe[rr] {expr1} .. Echo the expression(s) as an error message, saving the
message in the |message-history|. When used in a
+9 -1
View File
@@ -696,7 +696,10 @@ au BufNewFile,BufRead *.mo,*.gdmo setf gdmo
au BufNewFile,BufRead *.gd setf gdscript
" Godot resource
au BufRead,BufNewFile *.tscn,*.tres setf gdresource
au BufRead,BufNewFile *.tscn,*.tres setf gdresource
" Godot shader
au BufRead,BufNewFile *.gdshader,*.shader setf gdshader
" Gedcom
au BufNewFile,BufRead *.ged,lltxxxxx.txt setf gedcom
@@ -2091,6 +2094,11 @@ au BufNewFile,BufRead */.config/upstart/*.override setf upstart
" Vala
au BufNewFile,BufRead *.vala setf vala
" VDM
au BufRead,BufNewFile *.vdmpp,*.vpp setf vdmpp
au BufRead,BufNewFile *.vdmrt setf vdmrt
au BufRead,BufNewFile *.vdmsl,*.vdm setf vdmsl
" Vera
au BufNewFile,BufRead *.vr,*.vri,*.vrh setf vera
+50 -42
View File
@@ -170,38 +170,47 @@ update_screen(int type_arg)
if (msg_scrolled)
{
clear_cmdline = TRUE;
if (msg_scrolled > Rows - 5) // clearing is faster
type = UPD_CLEAR;
else if (type != UPD_CLEAR)
if (type != UPD_CLEAR)
{
check_for_delay(FALSE);
if (screen_ins_lines(0, 0, msg_scrolled, (int)Rows, 0, NULL)
== FAIL)
type = UPD_CLEAR;
FOR_ALL_WINDOWS(wp)
if (msg_scrolled > Rows - 5) // redrawing is faster
{
if (wp->w_winrow < msg_scrolled)
type = UPD_NOT_VALID;
redraw_as_cleared();
}
else
{
check_for_delay(FALSE);
if (screen_ins_lines(0, 0, msg_scrolled, (int)Rows, 0, NULL)
== FAIL)
{
if (W_WINROW(wp) + wp->w_height > msg_scrolled
&& wp->w_redr_type < UPD_REDRAW_TOP
&& wp->w_lines_valid > 0
&& wp->w_topline == wp->w_lines[0].wl_lnum)
type = UPD_NOT_VALID;
redraw_as_cleared();
}
FOR_ALL_WINDOWS(wp)
{
if (wp->w_winrow < msg_scrolled)
{
wp->w_upd_rows = msg_scrolled - W_WINROW(wp);
wp->w_redr_type = UPD_REDRAW_TOP;
}
else
{
wp->w_redr_type = UPD_NOT_VALID;
if (W_WINROW(wp) + wp->w_height + wp->w_status_height
<= msg_scrolled)
wp->w_redr_status = TRUE;
if (W_WINROW(wp) + wp->w_height > msg_scrolled
&& wp->w_redr_type < UPD_REDRAW_TOP
&& wp->w_lines_valid > 0
&& wp->w_topline == wp->w_lines[0].wl_lnum)
{
wp->w_upd_rows = msg_scrolled - W_WINROW(wp);
wp->w_redr_type = UPD_REDRAW_TOP;
}
else
{
wp->w_redr_type = UPD_NOT_VALID;
if (W_WINROW(wp) + wp->w_height
+ wp->w_status_height <= msg_scrolled)
wp->w_redr_status = TRUE;
}
}
}
if (!no_update)
redraw_cmdline = TRUE;
redraw_tabline = TRUE;
}
if (!no_update)
redraw_cmdline = TRUE;
redraw_tabline = TRUE;
}
msg_scrolled = 0;
need_wait_return = FALSE;
@@ -1921,24 +1930,9 @@ win_update(win_T *wp)
}
}
// When starting redraw in the first line, redraw all lines. When
// there is only one window it's probably faster to clear the screen
// first.
// When starting redraw in the first line, redraw all lines.
if (mid_start == 0)
{
mid_end = wp->w_height;
if (ONE_WINDOW && !WIN_IS_POPUP(wp))
{
// Clear the screen when it was not done by win_del_lines() or
// win_ins_lines() above, "screen_cleared" is FALSE or MAYBE
// then.
if (screen_cleared != TRUE)
screenclear();
// The screen was cleared, redraw the tab pages line.
if (redraw_tabline)
draw_tabline();
}
}
// When win_del_lines() or win_ins_lines() caused the screen to be
// cleared (only happens for the first window) or when screenclear()
@@ -3178,7 +3172,7 @@ redraw_later_clear(void)
}
/*
* Mark all windows to be redrawn later.
* Mark all windows to be redrawn later. Except popup windows.
*/
void
redraw_all_later(int type)
@@ -3191,6 +3185,20 @@ redraw_all_later(int type)
set_must_redraw(type);
}
#if 0 // not actually used yet, it probably should
/*
* Mark all windows, including popup windows, to be redrawn.
*/
void
redraw_all_windows_later(int type)
{
redraw_all_later(type);
#ifdef FEAT_PROP_POPUP
popup_redraw_all(); // redraw all popup windows
#endif
}
#endif
/*
* Set "must_redraw" to "type" unless it already has a higher value
* or it is currently not allowed.
+11 -3
View File
@@ -2078,7 +2078,8 @@ set_context_for_expression(
if ((cmdidx == CMD_execute
|| cmdidx == CMD_echo
|| cmdidx == CMD_echon
|| cmdidx == CMD_echomsg)
|| cmdidx == CMD_echomsg
|| cmdidx == CMD_echowindow)
&& xp->xp_context == EXPAND_EXPRESSION)
{
for (;;)
@@ -6709,6 +6710,7 @@ get_echo_attr(void)
/*
* ":execute expr1 ..." execute the result of an expression.
* ":echomsg expr1 ..." Print a message
* ":echowindow expr1 ..." Print a message in the messages window
* ":echoerr expr1 ..." Print an error
* ":echoconsole expr1 ..." Print a message on stdout
* Each gets spaces around each argument and a newline at the end for
@@ -6726,6 +6728,9 @@ ex_execute(exarg_T *eap)
long start_lnum = SOURCING_LNUM;
ga_init2(&ga, 1, 80);
#ifdef HAS_MESSAGE_WINDOW
in_echowindow = (eap->cmdidx == CMD_echowindow);
#endif
if (eap->skip)
++emsg_skip;
@@ -6780,7 +6785,9 @@ ex_execute(exarg_T *eap)
// use the first line of continuation lines for messages
SOURCING_LNUM = start_lnum;
if (eap->cmdidx == CMD_echomsg || eap->cmdidx == CMD_echoerr)
if (eap->cmdidx == CMD_echomsg
|| eap->cmdidx == CMD_echowindow
|| eap->cmdidx == CMD_echoerr)
{
// Mark the already saved text as finishing the line, so that what
// follows is displayed on a new line when scrolling back at the
@@ -6788,7 +6795,7 @@ ex_execute(exarg_T *eap)
msg_sb_eol();
}
if (eap->cmdidx == CMD_echomsg)
if (eap->cmdidx == CMD_echomsg || eap->cmdidx == CMD_echowindow)
{
msg_attr(ga.ga_data, echo_attr);
out_flush();
@@ -6835,6 +6842,7 @@ ex_execute(exarg_T *eap)
if (msg_col == 0)
msg_col = 1;
}
in_echowindow = FALSE;
#endif
set_nextcmd(eap, arg);
}
+23 -23
View File
@@ -10,27 +10,27 @@ static const unsigned short cmdidxs1[26] =
/* c */ 45,
/* d */ 112,
/* e */ 137,
/* f */ 165,
/* g */ 182,
/* h */ 188,
/* i */ 197,
/* j */ 217,
/* k */ 219,
/* l */ 224,
/* m */ 287,
/* n */ 307,
/* o */ 327,
/* p */ 339,
/* q */ 378,
/* r */ 381,
/* s */ 401,
/* t */ 471,
/* u */ 517,
/* v */ 528,
/* w */ 549,
/* x */ 563,
/* y */ 573,
/* z */ 574
/* f */ 166,
/* g */ 183,
/* h */ 189,
/* i */ 198,
/* j */ 218,
/* k */ 220,
/* l */ 225,
/* m */ 288,
/* n */ 308,
/* o */ 328,
/* p */ 340,
/* q */ 379,
/* r */ 382,
/* s */ 402,
/* t */ 472,
/* u */ 518,
/* v */ 529,
/* w */ 550,
/* x */ 564,
/* y */ 574,
/* z */ 575
};
/*
@@ -45,7 +45,7 @@ static const unsigned char cmdidxs2[26][26] =
/* b */ { 2, 0, 0, 5, 6, 8, 0, 0, 0, 0, 0, 9, 10, 11, 12, 13, 0, 14, 0, 0, 0, 0, 23, 0, 0, 0 },
/* c */ { 3, 12, 16, 18, 20, 22, 25, 0, 0, 0, 0, 33, 38, 41, 47, 57, 59, 60, 61, 0, 63, 0, 66, 0, 0, 0 },
/* d */ { 0, 0, 0, 0, 0, 0, 0, 0, 8, 18, 0, 19, 0, 0, 20, 0, 0, 22, 23, 0, 0, 0, 0, 0, 0, 0 },
/* e */ { 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 11, 0, 0, 0, 0, 0, 0, 0, 22, 0, 23, 0, 0 },
/* e */ { 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 9, 11, 12, 0, 0, 0, 0, 0, 0, 0, 23, 0, 24, 0, 0 },
/* f */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0 },
/* g */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 4, 5, 0, 0, 0, 0 },
/* h */ { 5, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
@@ -69,4 +69,4 @@ static const unsigned char cmdidxs2[26][26] =
/* z */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
static const int command_count = 591;
static const int command_count = 592;
+4 -2
View File
@@ -1011,6 +1011,7 @@ do_bang(
if (addr_count == 0) // :!
{
// echo the command
dont_use_message_window();
msg_start();
msg_putchar(':');
msg_putchar('!');
@@ -1150,7 +1151,8 @@ do_filter(
#if defined(FEAT_EVAL)
if (!aborting())
#endif
(void)semsg(_(e_cant_create_file_str), itmp); // will call wait_return
// will call wait_return()
(void)semsg(_(e_cant_create_file_str), itmp);
goto filterend;
}
if (curbuf != old_curbuf)
@@ -4330,7 +4332,7 @@ ex_substitute(exarg_T *eap)
// needed
msg_no_more = TRUE;
// write message same highlighting as for
// wait_return
// wait_return()
smsg_attr(HL_ATTR(HLF_R),
_("replace with %s (y/n/a/q/l/^E/^Y)?"), sub);
msg_no_more = FALSE;
+3
View File
@@ -548,6 +548,9 @@ EXCMD(CMD_echoconsole, "echoconsole", ex_execute,
EXCMD(CMD_echon, "echon", ex_echo,
EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_echowindow, "echowindow", ex_execute,
EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_else, "else", ex_else,
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
ADDR_NONE),
+1 -1
View File
@@ -421,7 +421,7 @@ check_changed_any(
if (!(p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)))
#endif
{
// There must be a wait_return for this message, do_buffer()
// There must be a wait_return() for this message, do_buffer()
// may cause a redraw. But wait_return() is a no-op when vgetc()
// is busy (Quit used from window menu), then make sure we don't
// cause a scroll up.
+2 -2
View File
@@ -885,7 +885,7 @@ do_cmdline(
, in_vim9script() ? GETLINE_CONCAT_CONTBAR
: GETLINE_CONCAT_CONT)) == NULL)
{
// Don't call wait_return for aborted command line. The NULL
// Don't call wait_return() for aborted command line. The NULL
// returned for the end of a sourced file or executed function
// doesn't do this.
if (KeyTyped && !(flags & DOCMD_REPEAT))
@@ -1361,7 +1361,7 @@ do_cmdline(
else if (need_wait_return)
{
/*
* The msg_start() above clears msg_didout. The wait_return we do
* The msg_start() above clears msg_didout. The wait_return() we do
* here should not overwrite the command that may be shown before
* doing that.
*/
+54 -65
View File
@@ -1666,7 +1666,7 @@ getcmdline_int(
if (!cmd_silent)
{
i = msg_scrolled;
msg_scrolled = 0; // avoid wait_return message
msg_scrolled = 0; // avoid wait_return() message
gotocmdline(TRUE);
msg_scrolled += i;
redrawcmdprompt(); // draw prompt or indent
@@ -2591,7 +2591,7 @@ theend:
made_cmdheight_nonzero = TRUE;
set_option_value((char_u *)"ch", 0L, NULL, 0);
// Redraw is needed for command line completion
redraw_all_later(UPD_CLEAR);
redraw_all_later(UPD_NOT_VALID);
made_cmdheight_nonzero = FALSE;
}
@@ -3884,6 +3884,8 @@ redrawcmdprompt(void)
void
redrawcmd(void)
{
int save_in_echowindow = in_echowindow;
if (cmd_silent)
return;
@@ -3895,6 +3897,9 @@ redrawcmd(void)
return;
}
// Do not put this in the message window.
in_echowindow = FALSE;
sb_text_restart_cmdline();
msg_start();
redrawcmdprompt();
@@ -3918,6 +3923,8 @@ redrawcmd(void)
// Typing ':' at the more prompt may set skip_redraw. We don't want this
// in cmdline mode
skip_redraw = FALSE;
in_echowindow = save_in_echowindow;
}
void
@@ -4126,6 +4133,30 @@ get_ccline_ptr(void)
}
#endif
#if defined(FEAT_EVAL) || defined(FEAT_CMDWIN)
/*
* Get the current command-line type.
* Returns ':' or '/' or '?' or '@' or '>' or '-'
* Only works when the command line is being edited.
* Returns NUL when something is wrong.
*/
static int
get_cmdline_type(void)
{
cmdline_info_T *p = get_ccline_ptr();
if (p == NULL)
return NUL;
if (p->cmdfirstc == NUL)
return
# ifdef FEAT_EVAL
(p->input_fn) ? '@' :
# endif
'-';
return p->cmdfirstc;
}
#endif
#if defined(FEAT_EVAL) || defined(PROTO)
/*
* Get the current command line in allocated memory.
@@ -4199,22 +4230,7 @@ f_getcmdpos(typval_T *argvars UNUSED, typval_T *rettv)
{
cmdline_info_T *p = get_ccline_ptr();
rettv->vval.v_number = 0;
if (p != NULL)
rettv->vval.v_number = p->cmdpos + 1;
}
/*
* Get the command line cursor screen position.
*/
static int
get_cmdline_screen_pos(void)
{
cmdline_info_T *p = get_ccline_ptr();
if (p == NULL)
return -1;
return p->cmdspos;
rettv->vval.v_number = p != NULL ? p->cmdpos + 1 : 0;
}
/*
@@ -4223,16 +4239,32 @@ get_cmdline_screen_pos(void)
void
f_getcmdscreenpos(typval_T *argvars UNUSED, typval_T *rettv)
{
rettv->vval.v_number = get_cmdline_screen_pos() + 1;
cmdline_info_T *p = get_ccline_ptr();
rettv->vval.v_number = p != NULL ? p->cmdspos + 1 : 0;
}
/*
* "getcmdtype()" function
*/
void
f_getcmdtype(typval_T *argvars UNUSED, typval_T *rettv)
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = alloc(2);
if (rettv->vval.v_string != NULL)
{
rettv->vval.v_string[0] = get_cmdline_type();
rettv->vval.v_string[1] = NUL;
}
}
// Set the command line str to "str".
// Returns 1 when failed, 0 when OK.
int
static int
set_cmdline_str(char_u *str, int pos)
{
cmdline_info_T *p = get_ccline_ptr();
int cmdline_type;
int len;
if (p == NULL)
@@ -4249,8 +4281,7 @@ set_cmdline_str(char_u *str, int pos)
redrawcmd();
// Trigger CmdlineChanged autocommands.
cmdline_type = ccline.cmdfirstc == NUL ? '-' : ccline.cmdfirstc;
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINECHANGED);
trigger_cmd_autocmd(get_cmdline_type(), EVENT_CMDLINECHANGED);
return 0;
}
@@ -4322,48 +4353,6 @@ f_setcmdpos(typval_T *argvars, typval_T *rettv)
}
#endif
#if defined(FEAT_EVAL) || defined(FEAT_CMDWIN)
/*
* Get the current command-line type.
* Returns ':' or '/' or '?' or '@' or '>' or '-'
* Only works when the command line is being edited.
* Returns NUL when something is wrong.
*/
static int
get_cmdline_type(void)
{
cmdline_info_T *p = get_ccline_ptr();
if (p == NULL)
return NUL;
if (p->cmdfirstc == NUL)
return
# ifdef FEAT_EVAL
(p->input_fn) ? '@' :
# endif
'-';
return p->cmdfirstc;
}
#endif
#if defined(FEAT_EVAL) || defined(PROTO)
/*
* "getcmdtype()" function
*/
void
f_getcmdtype(typval_T *argvars UNUSED, typval_T *rettv)
{
rettv->v_type = VAR_STRING;
rettv->vval.v_string = alloc(2);
if (rettv->vval.v_string != NULL)
{
rettv->vval.v_string[0] = get_cmdline_type();
rettv->vval.v_string[1] = NUL;
}
}
#endif
/*
* Return the first character of the current command line.
*/
+1 -1
View File
@@ -2098,7 +2098,7 @@ getchar_common(typval_T *argvars, typval_T *rettv)
// redraw the screen after getchar()
if (p_ch == 0)
update_screen(UPD_CLEAR);
update_screen(UPD_NOT_VALID);
set_vim_var_nr(VV_MOUSE_WIN, 0);
set_vim_var_nr(VV_MOUSE_WINID, 0);
+1
View File
@@ -236,6 +236,7 @@ EXTERN int uncaught_emsg; // number of times emsg() was
EXTERN int did_emsg_syntax; // did_emsg set because of a
// syntax error
EXTERN int called_emsg; // always incremented by emsg()
EXTERN int in_echowindow; // executing ":echowindow"
EXTERN int ex_exitval INIT(= 0); // exit value for ex mode
EXTERN int emsg_on_display INIT(= FALSE); // there is an error message
EXTERN int rc_did_emsg INIT(= FALSE); // vim_regcomp() called emsg()
+1 -1
View File
@@ -2474,7 +2474,7 @@ cs_show(exarg_T *eap UNUSED)
}
}
wait_return(TRUE);
wait_return(FALSE);
return CSCOPE_SUCCESS;
}
+2 -2
View File
@@ -674,7 +674,7 @@ vim_main2(void)
/*
* When done something that is not allowed or given an error message call
* wait_return. This must be done before starttermcap(), because it may
* wait_return(). This must be done before starttermcap(), because it may
* switch to another screen. It must be done after settmode(TMODE_RAW),
* because we want to react on a single key stroke.
* Call settmode and starttermcap here, so the T_KS and T_TI may be
@@ -1296,7 +1296,7 @@ main_loop(
did_check_timestamps = FALSE;
if (need_check_timestamps)
check_timestamps(FALSE);
if (need_wait_return) // if wait_return still needed ...
if (need_wait_return) // if wait_return() still needed ...
wait_return(FALSE); // ... call it now
if (need_start_insertmode && goto_im() && !VIsual_active)
{
+1 -1
View File
@@ -822,7 +822,7 @@ ml_open_file(buf_T *buf)
if (*p_dir != NUL && mfp->mf_fname == NULL)
{
need_wait_return = TRUE; // call wait_return later
need_wait_return = TRUE; // call wait_return() later
++no_wait_return;
(void)semsg(_(e_unable_to_open_swap_file_for_str_recovery_impossible),
buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname);
+14 -11
View File
@@ -94,7 +94,7 @@ static int verbose_did_open = FALSE;
/*
* msg(s) - displays the string 's' on the status line
* When terminal not initialized (yet) mch_errmsg(..) is used.
* return TRUE if wait_return not called
* return TRUE if wait_return() not called
*/
int
msg(char *s)
@@ -631,7 +631,7 @@ do_perror(char *msg)
* Rings the bell, if appropriate, and calls message() to do the real work
* When terminal not initialized (yet) mch_errmsg(..) is used.
*
* Return TRUE if wait_return not called.
* Return TRUE if wait_return() not called.
* Note: caller must check 'emsg_not_now()' before calling this.
*/
static int
@@ -758,7 +758,7 @@ emsg_core(char_u *s)
attr = HL_ATTR(HLF_E); // set highlight mode for error messages
if (msg_scrolled != 0)
need_wait_return = TRUE; // needed in case emsg() is called after
// wait_return has reset need_wait_return
// wait_return() has reset need_wait_return
// and a redraw is expected because
// msg_scrolled is non-zero
@@ -1443,7 +1443,8 @@ use_message_window(void)
#ifdef HAS_MESSAGE_WINDOW
// TRUE if there is no command line showing ('cmdheight' is zero and not
// already editing or showing a message) use a popup window for messages.
return p_ch == 0 && cmdline_row >= Rows;
// Also when using ":echowindow".
return (p_ch == 0 && cmdline_row >= Rows) || in_echowindow;
#else
return FALSE;
#endif
@@ -1477,7 +1478,7 @@ msg_start(void)
}
#ifdef FEAT_EVAL
if (need_clr_eos || p_ch == 0)
if (need_clr_eos || use_message_window())
{
// Halfway an ":echo" command and getting an (error) message: clear
// any text from the command.
@@ -1489,8 +1490,9 @@ msg_start(void)
#ifdef HAS_MESSAGE_WINDOW
if (use_message_window())
{
if (popup_message_win_visible() && msg_col > 0
&& (msg_scroll || !full_screen))
if (popup_message_win_visible()
&& ((msg_col > 0 && (msg_scroll || !full_screen))
|| in_echowindow))
{
win_T *wp = popup_get_message_win();
@@ -1513,8 +1515,9 @@ msg_start(void)
#endif
0;
}
else if (msg_didout || p_ch == 0) // start message on next line
else if (msg_didout || use_message_window())
{
// start message on next line
msg_putchar('\n');
did_return = TRUE;
if (exmode_active != EXMODE_NORMAL)
@@ -2460,7 +2463,7 @@ msg_puts_display(
{
#endif
inc_msg_scrolled();
need_wait_return = TRUE; // may need wait_return in main()
need_wait_return = TRUE; // may need wait_return() in main()
redraw_cmdline = TRUE;
if (cmdline_row > 0 && !exmode_active)
--cmdline_row;
@@ -3720,8 +3723,8 @@ msg_clr_cmdline(void)
/*
* end putting a message on the screen
* call wait_return if the message does not fit in the available space
* return TRUE if wait_return not called.
* call wait_return() if the message does not fit in the available space
* return TRUE if wait_return() not called.
*/
int
msg_end(void)
+1 -1
View File
@@ -616,7 +616,7 @@ ask_yesno(char_u *str, int direct)
while (r != 'y' && r != 'n')
{
// same highlighting as for wait_return
// same highlighting as for wait_return()
smsg_attr(HL_ATTR(HLF_R), "%s (y/n)?", str);
if (direct)
r = get_keystroke();
+1 -1
View File
@@ -2202,7 +2202,7 @@ skip:
// make sure all characters are printable
trans_characters(IObuff, IOSIZE);
++no_wait_return; // wait_return done later
++no_wait_return; // wait_return() done later
emsg((char *)IObuff); // show error highlighted
--no_wait_return;
+16 -1
View File
@@ -1302,7 +1302,8 @@ popup_adjust_position(win_T *wp)
}
if (wp->w_popup_pos == POPPOS_BOTTOM)
// assume that each buffer line takes one screen line
wp->w_winrow = MAX(Rows - wp->w_buffer->b_ml.ml_line_count - 1, 0);
wp->w_winrow = MAX(cmdline_row
- wp->w_buffer->b_ml.ml_line_count - 1, 0);
if (!use_wantcol)
center_hor = TRUE;
@@ -1937,6 +1938,20 @@ popup_terminal_exists(void)
}
#endif
/*
* Mark all popup windows in the current tab and global for redrawing.
*/
void
popup_redraw_all(void)
{
win_T *wp;
FOR_ALL_POPUPWINS(wp)
wp->w_redr_type = UPD_NOT_VALID;
FOR_ALL_POPUPWINS_IN_TAB(curtab, wp)
wp->w_redr_type = UPD_NOT_VALID;
}
/*
* Set the color for a notification window.
*/
+1 -2
View File
@@ -34,10 +34,9 @@ void f_getcmdcompltype(typval_T *argvars, typval_T *rettv);
void f_getcmdline(typval_T *argvars, typval_T *rettv);
void f_getcmdpos(typval_T *argvars, typval_T *rettv);
void f_getcmdscreenpos(typval_T *argvars, typval_T *rettv);
int set_cmdline_str(char_u *str, int pos);
void f_getcmdtype(typval_T *argvars, typval_T *rettv);
void f_setcmdline(typval_T *argvars, typval_T *rettv);
void f_setcmdpos(typval_T *argvars, typval_T *rettv);
void f_getcmdtype(typval_T *argvars, typval_T *rettv);
int get_cmdline_firstc(void);
int get_list_range(char_u **str, int *num1, int *num2);
char *check_cedit(void);
+1
View File
@@ -15,6 +15,7 @@ int parse_previewpopup(win_T *wp);
int parse_completepopup(win_T *wp);
void popup_set_wantpos_cursor(win_T *wp, int width, dict_T *d);
void popup_set_wantpos_rowcol(win_T *wp, int row, int col);
void popup_redraw_all(void);
void f_popup_clear(typval_T *argvars, typval_T *rettv);
void f_popup_create(typval_T *argvars, typval_T *rettv);
void f_popup_atcursor(typval_T *argvars, typval_T *rettv);
+1
View File
@@ -31,6 +31,7 @@ int screen_valid(int doclear);
void screenalloc(int doclear);
void free_screenlines(void);
void screenclear(void);
void redraw_as_cleared(void);
void line_was_clobbered(int screen_lnum);
int can_clear(char_u *p);
void screen_start(void);
+1 -1
View File
@@ -4761,7 +4761,7 @@ qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int qf_winid)
}
// Check if there is anything to display
if (qfl != NULL)
if (qfl != NULL && qfl->qf_start != NULL)
{
char_u dirname[MAXPATHL];
int invalid_val = FALSE;
+23 -6
View File
@@ -49,7 +49,7 @@
static int screen_attr = 0;
static void screen_char_2(unsigned off, int row, int col);
static void screenclear2(void);
static void screenclear2(int doclear);
static void lineclear(unsigned off, int width, int attr);
static void lineinvalid(unsigned off, int width);
static int win_do_lines(win_T *wp, int row, int line_count, int mayclear, int del, int clear_attr);
@@ -2947,7 +2947,7 @@ give_up:
set_must_redraw(UPD_CLEAR); // need to clear the screen later
if (doclear)
screenclear2();
screenclear2(TRUE);
#ifdef FEAT_GUI
else if (gui.in_use
&& !gui.starting
@@ -3010,16 +3010,30 @@ free_screenlines(void)
#endif
}
/*
* Clear the screen.
* May delay if there is something the user should read.
* Allocated the screen for resizing if needed.
*/
void
screenclear(void)
{
check_for_delay(FALSE);
screenalloc(FALSE); // allocate screen buffers if size changed
screenclear2(); // clear the screen
screenclear2(TRUE); // clear the screen
}
/*
* Do not clear the screen but mark everything for redraw.
*/
void
redraw_as_cleared(void)
{
screenclear2(FALSE);
}
static void
screenclear2(void)
screenclear2(int doclear)
{
int i;
@@ -3048,7 +3062,7 @@ screenclear2(void)
LineWraps[i] = FALSE;
}
if (can_clear(T_CL))
if (doclear && can_clear(T_CL))
{
out_str(T_CL); // clear the display
clear_cmdline = FALSE;
@@ -3064,7 +3078,10 @@ screenclear2(void)
screen_cleared = TRUE; // can use contents of ScreenLines now
win_rest_invalid(firstwin);
win_rest_invalid(firstwin); // redraw all regular windows
#ifdef FEAT_PROP_POPUP
popup_redraw_all(); // redraw all popup windows
#endif
redraw_cmdline = TRUE;
redraw_tabline = TRUE;
if (must_redraw == UPD_CLEAR) // no need to clear again
+1 -1
View File
@@ -2609,7 +2609,7 @@ typedef enum {
POPPOS_BOTRIGHT,
POPPOS_TOPRIGHT,
POPPOS_CENTER,
POPPOS_BOTTOM, // bottom of popup at bottom of screen
POPPOS_BOTTOM, // bottom of popup just above the command line
POPPOS_NONE
} poppos_T;
+8
View File
@@ -0,0 +1,8 @@
>s+0&#ffffff0|o|m|e| |t|e|x|t| @65
|~+0#4040ff13&| @73
|~| @73
|~| @73
|~| @73
|═+0#e000002&@74
|f|i|r|s|t| |l|i|n|e| @64
| +0#0000000&@56|1|,|1| @10|A|l@1|
+8
View File
@@ -0,0 +1,8 @@
>s+0&#ffffff0|o|m|e| |t|e|x|t| @65
|~+0#4040ff13&| @73
|~| @73
|~| @73
|═+0#e000002&@74
|f|i|r|s|t| |l|i|n|e| @64
|s|e|c|o|n|d| |l|i|n|e| @63
| +0#0000000&@56|1|,|1| @10|A|l@1|
+8
View File
@@ -0,0 +1,8 @@
>s+0&#ffffff0|o|m|e| |t|e|x|t| @65
|~+0#4040ff13&| @73
|~| @73
|~| @73
|~| @73
|~| @73
|~| @73
| +0#0000000&@56|1|,|1| @10|A|l@1|
@@ -2,7 +2,7 @@
|~+0#4040ff13&| @73
|~| @73
|~| @73
|~| @31| +0#0000000&@8| +0#4040ff13&@32
|~| @31|s+0#0000001#ffd7ff255|o|m|e| |t|e|x|t| +0#4040ff13#ffffff0@32
|~| @73
|~| @73
|~| @73
+4 -4
View File
@@ -56,10 +56,10 @@ func Test_acd_win_execute()
set acd
call test_autochdir()
call mkdir('Xfile')
call mkdir('XacdDir')
let winid = win_getid()
new Xfile/file
call assert_match('testdir.Xfile$', getcwd())
new XacdDir/file
call assert_match('testdir.XacdDir$', getcwd())
cd ..
call assert_match('testdir$', getcwd())
call win_execute(winid, 'echo')
@@ -68,7 +68,7 @@ func Test_acd_win_execute()
bwipe!
set noacd
call chdir(cwd)
call delete('Xfile', 'rf')
call delete('XacdDir', 'rf')
endfunc
func Test_verbose_pwd()
+33 -33
View File
@@ -24,29 +24,29 @@ endfunc
" Test for the CursorHold autocmd
func Test_CursorHold_autocmd()
CheckRunVimInTerminal
call writefile(['one', 'two', 'three'], 'Xfile')
call writefile(['one', 'two', 'three'], 'XoneTwoThree')
let before =<< trim END
set updatetime=10
au CursorHold * call writefile([line('.')], 'Xoutput', 'a')
au CursorHold * call writefile([line('.')], 'XCHoutput', 'a')
END
call writefile(before, 'Xinit')
let buf = RunVimInTerminal('-S Xinit Xfile', {})
call writefile(before, 'XCHinit')
let buf = RunVimInTerminal('-S XCHinit XoneTwoThree', {})
call term_sendkeys(buf, "G")
call term_wait(buf, 50)
call term_sendkeys(buf, "gg")
call term_wait(buf)
call WaitForAssert({-> assert_equal(['1'], readfile('Xoutput')[-1:-1])})
call WaitForAssert({-> assert_equal(['1'], readfile('XCHoutput')[-1:-1])})
call term_sendkeys(buf, "j")
call term_wait(buf)
call WaitForAssert({-> assert_equal(['1', '2'], readfile('Xoutput')[-2:-1])})
call WaitForAssert({-> assert_equal(['1', '2'], readfile('XCHoutput')[-2:-1])})
call term_sendkeys(buf, "j")
call term_wait(buf)
call WaitForAssert({-> assert_equal(['1', '2', '3'], readfile('Xoutput')[-3:-1])})
call WaitForAssert({-> assert_equal(['1', '2', '3'], readfile('XCHoutput')[-3:-1])})
call StopVimInTerminal(buf)
call delete('Xinit')
call delete('Xoutput')
call delete('Xfile')
call delete('XCHinit')
call delete('XCHoutput')
call delete('XoneTwoThree')
endfunc
if has('timers')
@@ -717,14 +717,14 @@ func Test_BufEnter()
call assert_equal('++', g:val)
" Also get BufEnter when editing a directory
call mkdir('Xdir')
split Xdir
call mkdir('Xbufenterdir')
split Xbufenterdir
call assert_equal('+++', g:val)
" On MS-Windows we can't edit the directory, make sure we wipe the right
" buffer.
bwipe! Xdir
call delete('Xdir', 'd')
bwipe! Xbufenterdir
call delete('Xbufenterdir', 'd')
au! BufEnter
" Editing a "nofile" buffer doesn't read the file but does trigger BufEnter
@@ -1521,21 +1521,21 @@ endfunc
" Test for Bufleave autocommand that deletes the buffer we are about to edit.
func Test_BufleaveWithDelete()
new | edit Xfile1
new | edit XbufLeave1
augroup test_bufleavewithdelete
autocmd!
autocmd BufLeave Xfile1 bwipe Xfile2
autocmd BufLeave XbufLeave1 bwipe XbufLeave2
augroup END
call assert_fails('edit Xfile2', 'E143:')
call assert_equal('Xfile1', bufname('%'))
call assert_fails('edit XbufLeave2', 'E143:')
call assert_equal('XbufLeave1', bufname('%'))
autocmd! test_bufleavewithdelete BufLeave Xfile1
autocmd! test_bufleavewithdelete BufLeave XbufLeave1
augroup! test_bufleavewithdelete
new
bwipe! Xfile1
bwipe! XbufLeave1
endfunc
" Test for autocommand that changes the buffer list, when doing ":ball".
@@ -2723,16 +2723,16 @@ func Test_throw_in_BufWritePre()
endfunc
func Test_autocmd_in_try_block()
call mkdir('Xdir')
call mkdir('Xintrydir')
au BufEnter * let g:fname = expand('%')
try
edit Xdir/
edit Xintrydir/
endtry
call assert_match('Xdir', g:fname)
call assert_match('Xintrydir', g:fname)
unlet g:fname
au! BufEnter
call delete('Xdir', 'rf')
call delete('Xintrydir', 'rf')
endfunc
func Test_autocmd_SafeState()
@@ -3007,13 +3007,13 @@ endfunc
func Test_BufReadPre_delfile()
augroup TestAuCmd
au!
autocmd BufReadPre Xfile call delete('Xfile')
autocmd BufReadPre XbufreadPre call delete('XbufreadPre')
augroup END
call writefile([], 'Xfile')
call assert_fails('new Xfile', 'E200:')
call assert_equal('Xfile', @%)
call writefile([], 'XbufreadPre')
call assert_fails('new XbufreadPre', 'E200:')
call assert_equal('XbufreadPre', @%)
call assert_equal(1, &readonly)
call delete('Xfile')
call delete('XbufreadPre')
augroup TestAuCmd
au!
augroup END
@@ -3024,13 +3024,13 @@ endfunc
func Test_BufReadPre_changebuf()
augroup TestAuCmd
au!
autocmd BufReadPre Xfile edit Xsomeotherfile
autocmd BufReadPre Xchangebuf edit Xsomeotherfile
augroup END
call writefile([], 'Xfile')
call assert_fails('new Xfile', 'E201:')
call writefile([], 'Xchangebuf')
call assert_fails('new Xchangebuf', 'E201:')
call assert_equal('Xsomeotherfile', @%)
call assert_equal(1, &readonly)
call delete('Xfile')
call delete('Xchangebuf')
augroup TestAuCmd
au!
augroup END
+3 -3
View File
@@ -78,11 +78,11 @@ endfunc
" Test for using a non-existing directory as a backup directory
func Test_non_existing_backupdir()
set backupdir=./non_existing_dir backupskip=
call writefile(['line1'], 'Xfile')
new Xfile
call writefile(['line1'], 'Xbackupdir')
new Xbackupdir
call assert_fails('write', 'E510:')
set backupdir&vim backupskip&vim
call delete('Xfile')
call delete('Xbackupdir')
endfunc
" vim: shiftwidth=2 sts=2 expandtab
+58 -58
View File
@@ -76,14 +76,14 @@ func Test_buflist_browse()
%bwipe!
call assert_fails('buffer 1000', 'E86:')
call writefile(['foo1', 'foo2', 'foo3', 'foo4'], 'Xfile1')
call writefile(['bar1', 'bar2', 'bar3', 'bar4'], 'Xfile2')
call writefile(['baz1', 'baz2', 'baz3', 'baz4'], 'Xfile3')
edit Xfile1
call writefile(['foo1', 'foo2', 'foo3', 'foo4'], 'Xbrowse1')
call writefile(['bar1', 'bar2', 'bar3', 'bar4'], 'Xbrowse2')
call writefile(['baz1', 'baz2', 'baz3', 'baz4'], 'Xbrowse3')
edit Xbrowse1
let b1 = bufnr()
edit Xfile2
edit Xbrowse2
let b2 = bufnr()
edit +/baz4 Xfile3
edit +/baz4 Xbrowse3
let b3 = bufnr()
call assert_fails('buffer ' .. b1 .. ' abc', 'E488:')
@@ -127,9 +127,9 @@ func Test_buflist_browse()
call assert_fails('sandbox bnext', 'E48:')
call delete('Xfile1')
call delete('Xfile2')
call delete('Xfile3')
call delete('Xbrowse1')
call delete('Xbrowse2')
call delete('Xbrowse3')
%bwipe!
endfunc
@@ -200,39 +200,39 @@ endfunc
" Test for quitting the 'swapfile exists' dialog with the split buffer
" command.
func Test_buffer_sbuf_cleanup()
call writefile([], 'Xfile')
call writefile([], 'XsplitCleanup')
" first open the file in a buffer
new Xfile
new XsplitCleanup
let bnr = bufnr()
close
" create the swap file
call writefile([], '.Xfile.swp')
call writefile([], '.XsplitCleanup.swp')
" Remove the catch-all that runtest.vim adds
au! SwapExists
augroup BufTest
au!
autocmd SwapExists Xfile let v:swapchoice='q'
autocmd SwapExists XsplitCleanup let v:swapchoice='q'
augroup END
exe 'sbuf ' . bnr
call assert_equal(1, winnr('$'))
call assert_equal(0, getbufinfo('Xfile')[0].loaded)
call assert_equal(0, getbufinfo('XsplitCleanup')[0].loaded)
" test for :sball
sball
call assert_equal(1, winnr('$'))
call assert_equal(0, getbufinfo('Xfile')[0].loaded)
call assert_equal(0, getbufinfo('XsplitCleanup')[0].loaded)
%bw!
set shortmess+=F
let v:statusmsg = ''
edit Xfile
edit XsplitCleanup
call assert_equal('', v:statusmsg)
call assert_equal(1, winnr('$'))
call assert_equal(0, getbufinfo('Xfile')[0].loaded)
call assert_equal(0, getbufinfo('XsplitCleanup')[0].loaded)
set shortmess&
call delete('Xfile')
call delete('.Xfile.swp')
call delete('XsplitCleanup')
call delete('.XsplitCleanup.swp')
augroup BufTest
au!
augroup END
@@ -261,35 +261,35 @@ func Test_goto_buf_with_confirm()
CheckUnix
CheckNotGui
CheckFeature dialog_con
new Xfile
new XgotoConf
enew
call setline(1, 'test')
call assert_fails('b Xfile', 'E37:')
call assert_fails('b XgotoConf', 'E37:')
call feedkeys('c', 'L')
call assert_fails('confirm b Xfile', 'E37:')
call assert_fails('confirm b XgotoConf', 'E37:')
call assert_equal(1, &modified)
call assert_equal('', @%)
call feedkeys('y', 'L')
call assert_fails('confirm b Xfile', ['', 'E37:'])
call assert_fails('confirm b XgotoConf', ['', 'E37:'])
call assert_equal(1, &modified)
call assert_equal('', @%)
call feedkeys('n', 'L')
confirm b Xfile
call assert_equal('Xfile', @%)
confirm b XgotoConf
call assert_equal('XgotoConf', @%)
close!
endfunc
" Test for splitting buffer with 'switchbuf'
func Test_buffer_switchbuf()
new Xfile
new Xswitchbuf
wincmd w
set switchbuf=useopen
sbuf Xfile
sbuf Xswitchbuf
call assert_equal(1, winnr())
call assert_equal(2, winnr('$'))
set switchbuf=usetab
tabnew
sbuf Xfile
sbuf Xswitchbuf
call assert_equal(1, tabpagenr())
call assert_equal(2, tabpagenr('$'))
set switchbuf&
@@ -301,11 +301,11 @@ func Test_bufadd_autocmd_bwipe()
%bw!
augroup BufAdd_Wipe
au!
autocmd BufAdd Xfile %bw!
autocmd BufAdd Xbwipe %bw!
augroup END
edit Xfile
edit Xbwipe
call assert_equal('', @%)
call assert_equal(0, bufexists('Xfile'))
call assert_equal(0, bufexists('Xbwipe'))
augroup BufAdd_Wipe
au!
augroup END
@@ -325,40 +325,40 @@ endfunc
" Test for using CTRL-^ to edit the alternative file keeping the cursor
" position with 'nostartofline'. Also test using the 'buf' command.
func Test_buffer_edit_altfile()
call writefile(repeat(['one two'], 50), 'Xfile1')
call writefile(repeat(['five six'], 50), 'Xfile2')
call writefile(repeat(['one two'], 50), 'Xaltfile1')
call writefile(repeat(['five six'], 50), 'Xaltfile2')
set nosol
edit Xfile1
edit Xaltfile1
call cursor(25, 5)
edit Xfile2
edit Xaltfile2
call cursor(30, 4)
exe "normal \<C-^>"
call assert_equal([0, 25, 5, 0], getpos('.'))
exe "normal \<C-^>"
call assert_equal([0, 30, 4, 0], getpos('.'))
buf Xfile1
buf Xaltfile1
call assert_equal([0, 25, 5, 0], getpos('.'))
buf Xfile2
buf Xaltfile2
call assert_equal([0, 30, 4, 0], getpos('.'))
set sol&
call delete('Xfile1')
call delete('Xfile2')
call delete('Xaltfile1')
call delete('Xaltfile2')
endfunc
" Test for running the :sball command with a maximum window count and a
" modified buffer
func Test_sball_with_count()
%bw!
edit Xfile1
edit Xcountfile1
call setline(1, ['abc'])
new Xfile2
new Xfile3
new Xfile4
new Xcountfile2
new Xcountfile3
new Xcountfile4
2sball
call assert_equal(bufnr('Xfile4'), winbufnr(1))
call assert_equal(bufnr('Xfile1'), winbufnr(2))
call assert_equal(0, getbufinfo('Xfile2')[0].loaded)
call assert_equal(0, getbufinfo('Xfile3')[0].loaded)
call assert_equal(bufnr('Xcountfile4'), winbufnr(1))
call assert_equal(bufnr('Xcountfile1'), winbufnr(2))
call assert_equal(0, getbufinfo('Xcountfile2')[0].loaded)
call assert_equal(0, getbufinfo('Xcountfile3')[0].loaded)
%bw!
endfunc
@@ -451,18 +451,18 @@ endfunc
func Test_buflist_alloc_failure()
%bw!
edit Xfile1
edit XallocFail1
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)
call assert_fails('edit Xfile2', 'E342:')
call assert_fails('edit XallocFail2', 'E342:')
" test for bufadd()
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)
call assert_fails('call bufadd("Xbuffer")', 'E342:')
" test for setting the arglist
edit Xfile2
edit XallocFail2
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)
call assert_fails('next Xfile3', 'E342:')
call assert_fails('next XallocFail3', 'E342:')
" test for setting the alternate buffer name when writing a file
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)
@@ -489,17 +489,17 @@ func Test_buflist_alloc_failure()
endif
" test for loading a new buffer after wiping out all the buffers
edit Xfile4
edit XallocFail4
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)
call assert_fails('%bw!', 'E342:')
" test for :checktime loading the buffer
call writefile(['one'], 'Xfile5')
call writefile(['one'], 'XallocFail5')
if has('unix')
edit Xfile5
edit XallocFail5
" sleep for some time to make sure the timestamp is different
sleep 200m
call writefile(['two'], 'Xfile5')
call writefile(['two'], 'XallocFail5')
set autoread
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)
call assert_fails('checktime', 'E342:')
@@ -509,12 +509,12 @@ func Test_buflist_alloc_failure()
" test for :vimgrep loading a dummy buffer
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)
call assert_fails('vimgrep two Xfile5', 'E342:')
call delete('Xfile5')
call assert_fails('vimgrep two XallocFail5', 'E342:')
call delete('XallocFail5')
" test for quickfix command loading a buffer
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)
call assert_fails('cexpr "Xfile6:10:Line10"', 'E342:')
call assert_fails('cexpr "XallocFail6:10:Line10"', 'E342:')
endfunc
" vim: shiftwidth=2 sts=2 expandtab
+13 -13
View File
@@ -69,11 +69,11 @@ endfunc
" Test for chdir()
func Test_chdir_func()
let topdir = getcwd()
call mkdir('Xdir/y/z', 'p')
call mkdir('Xchdir/y/z', 'p')
" Create a few tabpages and windows with different directories
new
cd Xdir
cd Xchdir
tabnew
tcd y
below new
@@ -81,22 +81,22 @@ func Test_chdir_func()
lcd z
tabfirst
call assert_match('^\[global\] .*/Xdir$', trim(execute('verbose pwd')))
call assert_match('^\[global\] .*/Xchdir$', trim(execute('verbose pwd')))
call chdir('..')
call assert_equal('y', fnamemodify(getcwd(1, 2), ':t'))
call assert_equal('z', fnamemodify(3->getcwd(2), ':t'))
tabnext | wincmd t
call assert_match('^\[tabpage\] .*/y$', trim(execute('verbose pwd')))
eval '..'->chdir()
call assert_equal('Xdir', fnamemodify(getcwd(1, 2), ':t'))
call assert_equal('Xdir', fnamemodify(getcwd(2, 2), ':t'))
call assert_equal('Xchdir', fnamemodify(getcwd(1, 2), ':t'))
call assert_equal('Xchdir', fnamemodify(getcwd(2, 2), ':t'))
call assert_equal('z', fnamemodify(getcwd(3, 2), ':t'))
call assert_equal('testdir', fnamemodify(getcwd(1, 1), ':t'))
3wincmd w
call assert_match('^\[window\] .*/z$', trim(execute('verbose pwd')))
call chdir('..')
call assert_equal('Xdir', fnamemodify(getcwd(1, 2), ':t'))
call assert_equal('Xdir', fnamemodify(getcwd(2, 2), ':t'))
call assert_equal('Xchdir', fnamemodify(getcwd(1, 2), ':t'))
call assert_equal('Xchdir', fnamemodify(getcwd(2, 2), ':t'))
call assert_equal('y', fnamemodify(getcwd(3, 2), ':t'))
call assert_equal('testdir', fnamemodify(getcwd(1, 1), ':t'))
@@ -110,20 +110,20 @@ func Test_chdir_func()
only | tabonly
call chdir(topdir)
call delete('Xdir', 'rf')
call delete('Xchdir', 'rf')
endfunc
" Test for changing to the previous directory '-'
func Test_prev_dir()
let topdir = getcwd()
call mkdir('Xdir/a/b/c', 'p')
call mkdir('Xprevdir/a/b/c', 'p')
" Create a few tabpages and windows with different directories
new | only
tabnew | new
tabnew
tabfirst
cd Xdir
cd Xprevdir
tabnext | wincmd t
tcd a
wincmd w
@@ -143,7 +143,7 @@ func Test_prev_dir()
" Check the directory of all the windows
tabfirst
call assert_equal('Xdir', fnamemodify(getcwd(), ':t'))
call assert_equal('Xprevdir', fnamemodify(getcwd(), ':t'))
tabnext | wincmd t
call assert_equal('a', fnamemodify(getcwd(), ':t'))
wincmd w
@@ -163,7 +163,7 @@ func Test_prev_dir()
" Check the directory of all the windows
tabfirst
call assert_equal('Xdir', fnamemodify(getcwd(), ':t'))
call assert_equal('Xprevdir', fnamemodify(getcwd(), ':t'))
tabnext | wincmd t
call assert_equal('a', fnamemodify(getcwd(), ':t'))
wincmd w
@@ -173,7 +173,7 @@ func Test_prev_dir()
only | tabonly
call chdir(topdir)
call delete('Xdir', 'rf')
call delete('Xprevdir', 'rf')
endfunc
func Test_lcd_split()
+3 -3
View File
@@ -2281,9 +2281,9 @@ func Test_zz_ch_log()
let text = readfile('Xlog')
call assert_match("hello there", text[1])
call assert_match("%s%s", text[2])
call mkdir("Xdir1")
call assert_fails("call ch_logfile('Xdir1')", 'E484:')
cal delete("Xdir1", 'd')
call mkdir("Xchlogdir1")
call assert_fails("call ch_logfile('Xchlogdir1')", 'E484:')
cal delete("Xchlogdir1", 'd')
call delete('Xlog')
endfunc
+37 -37
View File
@@ -2,28 +2,28 @@
" Test for 'include' without \zs or \ze
func Test_checkpath1()
call mkdir("Xdir1/dir2", "p")
call writefile(['#include "bar.a"'], 'Xdir1/dir2/foo.a')
call writefile(['#include "baz.a"'], 'Xdir1/dir2/bar.a')
call writefile(['#include "foo.a"'], 'Xdir1/dir2/baz.a')
call mkdir("Xcheckdir1/dir2", "p")
call writefile(['#include "bar.a"'], 'Xcheckdir1/dir2/foo.a')
call writefile(['#include "baz.a"'], 'Xcheckdir1/dir2/bar.a')
call writefile(['#include "foo.a"'], 'Xcheckdir1/dir2/baz.a')
call writefile(['#include <foo.a>'], 'Xbase.a')
edit Xbase.a
set path=Xdir1/dir2
set path=Xcheckdir1/dir2
let res = split(execute("checkpath!"), "\n")
call assert_equal([
\ '--- Included files in path ---',
\ 'Xdir1/dir2/foo.a',
\ 'Xdir1/dir2/foo.a -->',
\ ' Xdir1/dir2/bar.a',
\ ' Xdir1/dir2/bar.a -->',
\ ' Xdir1/dir2/baz.a',
\ ' Xdir1/dir2/baz.a -->',
\ 'Xcheckdir1/dir2/foo.a',
\ 'Xcheckdir1/dir2/foo.a -->',
\ ' Xcheckdir1/dir2/bar.a',
\ ' Xcheckdir1/dir2/bar.a -->',
\ ' Xcheckdir1/dir2/baz.a',
\ ' Xcheckdir1/dir2/baz.a -->',
\ ' "foo.a" (Already listed)'], res)
enew
call delete("./Xbase.a")
call delete("Xdir1", "rf")
call delete("Xcheckdir1", "rf")
set path&
endfunc
@@ -33,31 +33,31 @@ endfunc
" Test for 'include' with \zs and \ze
func Test_checkpath2()
call mkdir("Xdir1/dir2", "p")
call writefile(['%inc /bar/'], 'Xdir1/dir2/foo.b')
call writefile(['%inc /baz/'], 'Xdir1/dir2/bar.b')
call writefile(['%inc /foo/'], 'Xdir1/dir2/baz.b')
call mkdir("Xcheckdir2/dir2", "p")
call writefile(['%inc /bar/'], 'Xcheckdir2/dir2/foo.b')
call writefile(['%inc /baz/'], 'Xcheckdir2/dir2/bar.b')
call writefile(['%inc /foo/'], 'Xcheckdir2/dir2/baz.b')
call writefile(['%inc /foo/'], 'Xbase.b')
let &include='^\s*%inc\s*/\zs[^/]\+\ze'
let &includeexpr='DotsToSlashes()'
edit Xbase.b
set path=Xdir1/dir2
set path=Xcheckdir2/dir2
let res = split(execute("checkpath!"), "\n")
call assert_equal([
\ '--- Included files in path ---',
\ 'Xdir1/dir2/foo.b',
\ 'Xdir1/dir2/foo.b -->',
\ ' Xdir1/dir2/bar.b',
\ ' Xdir1/dir2/bar.b -->',
\ ' Xdir1/dir2/baz.b',
\ ' Xdir1/dir2/baz.b -->',
\ 'Xcheckdir2/dir2/foo.b',
\ 'Xcheckdir2/dir2/foo.b -->',
\ ' Xcheckdir2/dir2/bar.b',
\ ' Xcheckdir2/dir2/bar.b -->',
\ ' Xcheckdir2/dir2/baz.b',
\ ' Xcheckdir2/dir2/baz.b -->',
\ ' foo (Already listed)'], res)
enew
call delete("./Xbase.b")
call delete("Xdir1", "rf")
call delete("Xcheckdir2", "rf")
set path&
set include&
set includeexpr&
@@ -72,32 +72,32 @@ endfunc
" Test for 'include' with \zs and no \ze
func Test_checkpath3()
call mkdir("Xdir1/dir2", "p")
call writefile(['%inc bar.c'], 'Xdir1/dir2/foo.c')
call writefile(['%inc baz.c'], 'Xdir1/dir2/bar.c')
call writefile(['%inc foo.c'], 'Xdir1/dir2/baz.c')
call writefile(['%inc foo.c'], 'Xdir1/dir2/FALSE.c')
call mkdir("Xcheckdir3/dir2", "p")
call writefile(['%inc bar.c'], 'Xcheckdir3/dir2/foo.c')
call writefile(['%inc baz.c'], 'Xcheckdir3/dir2/bar.c')
call writefile(['%inc foo.c'], 'Xcheckdir3/dir2/baz.c')
call writefile(['%inc foo.c'], 'Xcheckdir3/dir2/FALSE.c')
call writefile(['%inc FALSE.c foo.c'], 'Xbase.c')
let &include='^\s*%inc\s*\%([[:upper:]][^[:space:]]*\s\+\)\?\zs\S\+\ze'
let &includeexpr='StripNewlineChar()'
edit Xbase.c
set path=Xdir1/dir2
set path=Xcheckdir3/dir2
let res = split(execute("checkpath!"), "\n")
call assert_equal([
\ '--- Included files in path ---',
\ 'Xdir1/dir2/foo.c',
\ 'Xdir1/dir2/foo.c -->',
\ ' Xdir1/dir2/bar.c',
\ ' Xdir1/dir2/bar.c -->',
\ ' Xdir1/dir2/baz.c',
\ ' Xdir1/dir2/baz.c -->',
\ 'Xcheckdir3/dir2/foo.c',
\ 'Xcheckdir3/dir2/foo.c -->',
\ ' Xcheckdir3/dir2/bar.c',
\ ' Xcheckdir3/dir2/bar.c -->',
\ ' Xcheckdir3/dir2/baz.c',
\ ' Xcheckdir3/dir2/baz.c -->',
\ ' foo.c (Already listed)'], res)
enew
call delete("./Xbase.c")
call delete("Xdir1", "rf")
call delete("Xcheckdir3", "rf")
set path&
set include&
set includeexpr&
+50 -37
View File
@@ -83,38 +83,38 @@ func Test_complete_list()
endfunc
func Test_complete_wildmenu()
call mkdir('Xdir1/Xdir2', 'p')
call writefile(['testfile1'], 'Xdir1/Xtestfile1')
call writefile(['testfile2'], 'Xdir1/Xtestfile2')
call writefile(['testfile3'], 'Xdir1/Xdir2/Xtestfile3')
call writefile(['testfile3'], 'Xdir1/Xdir2/Xtestfile4')
call mkdir('Xwilddir1/Xdir2', 'p')
call writefile(['testfile1'], 'Xwilddir1/Xtestfile1')
call writefile(['testfile2'], 'Xwilddir1/Xtestfile2')
call writefile(['testfile3'], 'Xwilddir1/Xdir2/Xtestfile3')
call writefile(['testfile3'], 'Xwilddir1/Xdir2/Xtestfile4')
set wildmenu
" Pressing <Tab> completes, and moves to next files when pressing again.
call feedkeys(":e Xdir1/\<Tab>\<Tab>\<CR>", 'tx')
call feedkeys(":e Xwilddir1/\<Tab>\<Tab>\<CR>", 'tx')
call assert_equal('testfile1', getline(1))
call feedkeys(":e Xdir1/\<Tab>\<Tab>\<Tab>\<CR>", 'tx')
call feedkeys(":e Xwilddir1/\<Tab>\<Tab>\<Tab>\<CR>", 'tx')
call assert_equal('testfile2', getline(1))
" <S-Tab> is like <Tab> but begin with the last match and then go to
" previous.
call feedkeys(":e Xdir1/Xtest\<S-Tab>\<CR>", 'tx')
call feedkeys(":e Xwilddir1/Xtest\<S-Tab>\<CR>", 'tx')
call assert_equal('testfile2', getline(1))
call feedkeys(":e Xdir1/Xtest\<S-Tab>\<S-Tab>\<CR>", 'tx')
call feedkeys(":e Xwilddir1/Xtest\<S-Tab>\<S-Tab>\<CR>", 'tx')
call assert_equal('testfile1', getline(1))
" <Left>/<Right> to move to previous/next file.
call feedkeys(":e Xdir1/\<Tab>\<Right>\<CR>", 'tx')
call feedkeys(":e Xwilddir1/\<Tab>\<Right>\<CR>", 'tx')
call assert_equal('testfile1', getline(1))
call feedkeys(":e Xdir1/\<Tab>\<Right>\<Right>\<CR>", 'tx')
call feedkeys(":e Xwilddir1/\<Tab>\<Right>\<Right>\<CR>", 'tx')
call assert_equal('testfile2', getline(1))
call feedkeys(":e Xdir1/\<Tab>\<Right>\<Right>\<Left>\<CR>", 'tx')
call feedkeys(":e Xwilddir1/\<Tab>\<Right>\<Right>\<Left>\<CR>", 'tx')
call assert_equal('testfile1', getline(1))
" <Up>/<Down> to go up/down directories.
call feedkeys(":e Xdir1/\<Tab>\<Down>\<CR>", 'tx')
call feedkeys(":e Xwilddir1/\<Tab>\<Down>\<CR>", 'tx')
call assert_equal('testfile3', getline(1))
call feedkeys(":e Xdir1/\<Tab>\<Down>\<Up>\<Right>\<CR>", 'tx')
call feedkeys(":e Xwilddir1/\<Tab>\<Down>\<Up>\<Right>\<CR>", 'tx')
call assert_equal('testfile1', getline(1))
" this fails in some Unix GUIs, not sure why
@@ -124,9 +124,9 @@ func Test_complete_wildmenu()
set wildcharm=<C-Z>
cnoremap <C-J> <Down><C-Z>
cnoremap <C-K> <Up><C-Z>
call feedkeys(":e Xdir1/\<Tab>\<C-J>\<CR>", 'tx')
call feedkeys(":e Xwilddir1/\<Tab>\<C-J>\<CR>", 'tx')
call assert_equal('testfile3', getline(1))
call feedkeys(":e Xdir1/\<Tab>\<C-J>\<C-K>\<CR>", 'tx')
call feedkeys(":e Xwilddir1/\<Tab>\<C-J>\<C-K>\<CR>", 'tx')
call assert_equal('testfile1', getline(1))
set wildcharm=0
cunmap <C-J>
@@ -135,21 +135,21 @@ func Test_complete_wildmenu()
" Test for canceling the wild menu by adding a character
redrawstatus
call feedkeys(":e Xdir1/\<Tab>x\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xdir1/Xdir2/x', @:)
call feedkeys(":e Xwilddir1/\<Tab>x\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xwilddir1/Xdir2/x', @:)
" Completion using a relative path
cd Xdir1/Xdir2
cd Xwilddir1/Xdir2
call feedkeys(":e ../\<Tab>\<Right>\<Down>\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"e Xtestfile3 Xtestfile4', @:)
cd -
" test for wildmenumode()
cnoremap <expr> <F2> wildmenumode()
call feedkeys(":cd Xdir\<Tab>\<F2>\<C-B>\"\<CR>", 'tx')
call assert_equal('"cd Xdir1/0', @:)
call feedkeys(":e Xdir1/\<Tab>\<F2>\<C-B>\"\<CR>", 'tx')
call assert_equal('"e Xdir1/Xdir2/1', @:)
call feedkeys(":cd Xwilddir\<Tab>\<F2>\<C-B>\"\<CR>", 'tx')
call assert_equal('"cd Xwilddir1/0', @:)
call feedkeys(":e Xwilddir1/\<Tab>\<F2>\<C-B>\"\<CR>", 'tx')
call assert_equal('"e Xwilddir1/Xdir2/1', @:)
cunmap <F2>
" Test for canceling the wild menu by pressing <PageDown> or <PageUp>.
@@ -162,7 +162,7 @@ func Test_complete_wildmenu()
" cleanup
%bwipe
call delete('Xdir1', 'rf')
call delete('Xwilddir1', 'rf')
set nowildmenu
endfunc
@@ -1930,18 +1930,18 @@ endfunc
func Test_wildmenu_dirstack()
CheckUnix
%bw!
call mkdir('Xdir1/dir2/dir3/dir4', 'p')
call writefile([], 'Xdir1/file1_1.txt')
call writefile([], 'Xdir1/file1_2.txt')
call writefile([], 'Xdir1/dir2/file2_1.txt')
call writefile([], 'Xdir1/dir2/file2_2.txt')
call writefile([], 'Xdir1/dir2/dir3/file3_1.txt')
call writefile([], 'Xdir1/dir2/dir3/file3_2.txt')
call writefile([], 'Xdir1/dir2/dir3/dir4/file4_1.txt')
call writefile([], 'Xdir1/dir2/dir3/dir4/file4_2.txt')
call mkdir('Xwildmenu/dir2/dir3/dir4', 'p')
call writefile([], 'Xwildmenu/file1_1.txt')
call writefile([], 'Xwildmenu/file1_2.txt')
call writefile([], 'Xwildmenu/dir2/file2_1.txt')
call writefile([], 'Xwildmenu/dir2/file2_2.txt')
call writefile([], 'Xwildmenu/dir2/dir3/file3_1.txt')
call writefile([], 'Xwildmenu/dir2/dir3/file3_2.txt')
call writefile([], 'Xwildmenu/dir2/dir3/dir4/file4_1.txt')
call writefile([], 'Xwildmenu/dir2/dir3/dir4/file4_2.txt')
set wildmenu
cd Xdir1/dir2/dir3/dir4
cd Xwildmenu/dir2/dir3/dir4
call feedkeys(":e \<Tab>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e file4_1.txt', @:)
call feedkeys(":e \<Tab>\<Up>\<C-B>\"\<CR>", 'xt')
@@ -1955,10 +1955,10 @@ func Test_wildmenu_dirstack()
call feedkeys(":e \<Tab>\<Up>\<Up>\<Down>\<Down>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e ../../dir3/dir4/file4_1.txt', @:)
cd -
call feedkeys(":e Xdir1/\<Tab>\<Down>\<Down>\<Down>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xdir1/dir2/dir3/dir4/file4_1.txt', @:)
call feedkeys(":e Xwildmenu/\<Tab>\<Down>\<Down>\<Down>\<C-B>\"\<CR>", 'xt')
call assert_equal('"e Xwildmenu/dir2/dir3/dir4/file4_1.txt', @:)
call delete('Xdir1', 'rf')
call delete('Xwildmenu', 'rf')
set wildmenu&
endfunc
@@ -3264,9 +3264,13 @@ endfunc
func Test_setcmdline()
func SetText(text, pos)
autocmd CmdlineChanged * let g:cmdtype = expand('<afile>')
call assert_equal(0, setcmdline(a:text))
call assert_equal(a:text, getcmdline())
call assert_equal(len(a:text) + 1, getcmdpos())
call assert_equal(getcmdtype(), g:cmdtype)
unlet g:cmdtype
autocmd! CmdlineChanged
call assert_equal(0, setcmdline(a:text, a:pos))
call assert_equal(a:text, getcmdline())
@@ -3282,6 +3286,13 @@ func Test_setcmdline()
call feedkeys(":\<C-R>=SetText('set rtp?', 2)\<CR>\<CR>", 'xt')
call assert_equal('set rtp?', @:)
call feedkeys(":let g:str = input('? ')\<CR>", 't')
call feedkeys("\<C-R>=SetText('foo', 4)\<CR>\<CR>", 'xt')
call assert_equal('foo', g:str)
unlet g:str
delfunc SetText
" setcmdline() returns 1 when not editing the command line.
call assert_equal(1, 'foo'->setcmdline())
@@ -3294,6 +3305,8 @@ func Test_setcmdline()
com! -nargs=* -complete=custom,CustomComplete DoCmd :
call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"DoCmd January February Mars', @:)
delcom DoCmd
delfunc CustomComplete
" Called in <expr>
cnoremap <expr>a setcmdline('let foo=')
+54 -54
View File
@@ -14,32 +14,32 @@ func Test_file_delete()
endfunc
func Test_dir_delete()
call mkdir('Xdir1')
call assert_true(isdirectory('Xdir1'))
call assert_equal(0, delete('Xdir1', 'd'))
call assert_false(isdirectory('Xdir1'))
call assert_equal(-1, delete('Xdir1', 'd'))
call mkdir('Xdirdel')
call assert_true(isdirectory('Xdirdel'))
call assert_equal(0, delete('Xdirdel', 'd'))
call assert_false(isdirectory('Xdirdel'))
call assert_equal(-1, delete('Xdirdel', 'd'))
endfunc
func Test_recursive_delete()
call mkdir('Xdir1')
call mkdir('Xdir1/subdir')
call mkdir('Xdir1/empty')
split Xdir1/Xfile
call mkdir('Xrecdel')
call mkdir('Xrecdel/subdir')
call mkdir('Xrecdel/empty')
split Xrecdel/Xfile
call setline(1, ['a', 'b'])
w
w Xdir1/subdir/Xfile
w Xrecdel/subdir/Xfile
close
call assert_true(isdirectory('Xdir1'))
call assert_equal(['a', 'b'], readfile('Xdir1/Xfile'))
call assert_true(isdirectory('Xdir1/subdir'))
call assert_equal(['a', 'b'], readfile('Xdir1/subdir/Xfile'))
call assert_true('Xdir1/empty'->isdirectory())
call assert_equal(0, delete('Xdir1', 'rf'))
call assert_false(isdirectory('Xdir1'))
call assert_equal(-1, delete('Xdir1', 'd'))
bwipe Xdir1/Xfile
bwipe Xdir1/subdir/Xfile
call assert_true(isdirectory('Xrecdel'))
call assert_equal(['a', 'b'], readfile('Xrecdel/Xfile'))
call assert_true(isdirectory('Xrecdel/subdir'))
call assert_equal(['a', 'b'], readfile('Xrecdel/subdir/Xfile'))
call assert_true('Xrecdel/empty'->isdirectory())
call assert_equal(0, delete('Xrecdel', 'rf'))
call assert_false(isdirectory('Xrecdel'))
call assert_equal(-1, delete('Xrecdel', 'd'))
bwipe Xrecdel/Xfile
bwipe Xrecdel/subdir/Xfile
endfunc
func Test_symlink_delete()
@@ -47,59 +47,59 @@ func Test_symlink_delete()
split Xfile
call setline(1, ['a', 'b'])
wq
silent !ln -s Xfile Xlink
silent !ln -s Xfile Xdellink
" Delete the link, not the file
call assert_equal(0, delete('Xlink'))
call assert_equal(-1, delete('Xlink'))
call assert_equal(0, delete('Xdellink'))
call assert_equal(-1, delete('Xdellink'))
call assert_equal(0, delete('Xfile'))
bwipe Xfile
endfunc
func Test_symlink_dir_delete()
CheckUnix
call mkdir('Xdir1')
silent !ln -s Xdir1 Xlink
call assert_true(isdirectory('Xdir1'))
call assert_true(isdirectory('Xlink'))
call mkdir('Xsymdir')
silent !ln -s Xsymdir Xdirlink
call assert_true(isdirectory('Xsymdir'))
call assert_true(isdirectory('Xdirlink'))
" Delete the link, not the directory
call assert_equal(0, delete('Xlink'))
call assert_equal(-1, delete('Xlink'))
call assert_equal(0, delete('Xdir1', 'd'))
call assert_equal(0, delete('Xdirlink'))
call assert_equal(-1, delete('Xdirlink'))
call assert_equal(0, delete('Xsymdir', 'd'))
endfunc
func Test_symlink_recursive_delete()
CheckUnix
call mkdir('Xdir3')
call mkdir('Xdir3/subdir')
call mkdir('Xdir4')
split Xdir3/Xfile
call mkdir('Xrecdir3')
call mkdir('Xrecdir3/subdir')
call mkdir('Xrecdir4')
split Xrecdir3/Xfile
call setline(1, ['a', 'b'])
w
w Xdir3/subdir/Xfile
w Xdir4/Xfile
w Xrecdir3/subdir/Xfile
w Xrecdir4/Xfile
close
silent !ln -s ../Xdir4 Xdir3/Xlink
silent !ln -s ../Xrecdir4 Xrecdir3/Xreclink
call assert_true(isdirectory('Xdir3'))
call assert_equal(['a', 'b'], readfile('Xdir3/Xfile'))
call assert_true(isdirectory('Xdir3/subdir'))
call assert_equal(['a', 'b'], readfile('Xdir3/subdir/Xfile'))
call assert_true(isdirectory('Xdir4'))
call assert_true(isdirectory('Xdir3/Xlink'))
call assert_equal(['a', 'b'], readfile('Xdir4/Xfile'))
call assert_true(isdirectory('Xrecdir3'))
call assert_equal(['a', 'b'], readfile('Xrecdir3/Xfile'))
call assert_true(isdirectory('Xrecdir3/subdir'))
call assert_equal(['a', 'b'], readfile('Xrecdir3/subdir/Xfile'))
call assert_true(isdirectory('Xrecdir4'))
call assert_true(isdirectory('Xrecdir3/Xreclink'))
call assert_equal(['a', 'b'], readfile('Xrecdir4/Xfile'))
call assert_equal(0, delete('Xdir3', 'rf'))
call assert_false(isdirectory('Xdir3'))
call assert_equal(-1, delete('Xdir3', 'd'))
call assert_equal(0, delete('Xrecdir3', 'rf'))
call assert_false(isdirectory('Xrecdir3'))
call assert_equal(-1, delete('Xrecdir3', 'd'))
" symlink is deleted, not the directory it points to
call assert_true(isdirectory('Xdir4'))
call assert_equal(['a', 'b'], readfile('Xdir4/Xfile'))
call assert_equal(0, delete('Xdir4/Xfile'))
call assert_equal(0, delete('Xdir4', 'd'))
call assert_true(isdirectory('Xrecdir4'))
call assert_equal(['a', 'b'], readfile('Xrecdir4/Xfile'))
call assert_equal(0, delete('Xrecdir4/Xfile'))
call assert_equal(0, delete('Xrecdir4', 'd'))
bwipe Xdir3/Xfile
bwipe Xdir3/subdir/Xfile
bwipe Xdir4/Xfile
bwipe Xrecdir3/Xfile
bwipe Xrecdir3/subdir/Xfile
bwipe Xrecdir4/Xfile
endfunc
func Test_delete_errors()
+2 -2
View File
@@ -1495,7 +1495,7 @@ func Test_edit_complete_very_long_name()
" Long directory names only work on Unix.
CheckUnix
let dirname = getcwd() . "/Xdir"
let dirname = getcwd() . "/Xlongdir"
let longdirname = dirname . repeat('/' . repeat('d', 255), 4)
try
call mkdir(longdirname, 'p')
@@ -1732,7 +1732,7 @@ endfunc
" Test for editing a directory
func Test_edit_is_a_directory()
CheckEnglish
let dirname = getcwd() . "/Xdir"
let dirname = getcwd() . "/Xeditdir"
call mkdir(dirname, 'p')
new
+3 -3
View File
@@ -489,9 +489,9 @@ func Test_redir_cmd()
if has('unix')
" Redirecting to a directory name
call mkdir('Xdir')
call assert_fails('redir > Xdir', 'E17:')
call delete('Xdir', 'd')
call mkdir('Xredir')
call assert_fails('redir > Xredir', 'E17:')
call delete('Xredir', 'd')
endif
" Test for redirecting to a register
+4
View File
@@ -209,6 +209,7 @@ let s:filename_checks = {
\ 'gdmo': ['file.mo', 'file.gdmo'],
\ 'gdresource': ['file.tscn', 'file.tres'],
\ 'gdscript': ['file.gd'],
\ 'gdshader': ['file.gdshader', 'file.shader'],
\ 'gedcom': ['file.ged', 'lltxxxxx.txt', '/tmp/lltmp', '/tmp/lltmp-file', 'any/tmp/lltmp', 'any/tmp/lltmp-file'],
\ 'gemtext': ['file.gmi', 'file.gemini'],
\ 'gift': ['file.gift'],
@@ -589,6 +590,9 @@ let s:filename_checks = {
\ 'usw2kagtlog': ['usw2kagt.log', 'USW2KAGT.LOG', 'usw2kagt.file.log', 'USW2KAGT.FILE.LOG', 'file.usw2kagt.log', 'FILE.USW2KAGT.LOG'],
\ 'vala': ['file.vala'],
\ 'vb': ['file.sba', 'file.vb', 'file.vbs', 'file.dsm', 'file.ctl'],
\ 'vdmpp': ['file.vpp', 'file.vdmpp'],
\ 'vdmrt': ['file.vdmrt'],
\ 'vdmsl': ['file.vdm', 'file.vdmsl'],
\ 'vera': ['file.vr', 'file.vri', 'file.vrh'],
\ 'verilog': ['file.v'],
\ 'verilogams': ['file.va', 'file.vams'],
+34 -34
View File
@@ -1,14 +1,14 @@
" Test findfile() and finddir()
let s:files = [ 'Xdir1/foo',
\ 'Xdir1/bar',
\ 'Xdir1/Xdir2/foo',
\ 'Xdir1/Xdir2/foobar',
\ 'Xdir1/Xdir2/Xdir3/bar',
\ 'Xdir1/Xdir2/Xdir3/barfoo' ]
let s:files = [ 'Xfinddir1/foo',
\ 'Xfinddir1/bar',
\ 'Xfinddir1/Xdir2/foo',
\ 'Xfinddir1/Xdir2/foobar',
\ 'Xfinddir1/Xdir2/Xdir3/bar',
\ 'Xfinddir1/Xdir2/Xdir3/barfoo' ]
func CreateFiles()
call mkdir('Xdir1/Xdir2/Xdir3/Xdir2', 'p')
call mkdir('Xfinddir1/Xdir2/Xdir3/Xdir2', 'p')
for f in s:files
call writefile([], f)
endfor
@@ -16,15 +16,15 @@ endfunc
func CleanFiles()
" Safer to delete each file even if it's more verbose
" than doing a recursive delete('Xdir1', 'rf').
" than doing a recursive delete('Xfinddir1', 'rf').
for f in s:files
call delete(f)
endfor
call delete('Xdir1/Xdir2/Xdir3/Xdir2', 'd')
call delete('Xdir1/Xdir2/Xdir3', 'd')
call delete('Xdir1/Xdir2', 'd')
call delete('Xdir1', 'd')
call delete('Xfinddir1/Xdir2/Xdir3/Xdir2', 'd')
call delete('Xfinddir1/Xdir2/Xdir3', 'd')
call delete('Xfinddir1/Xdir2', 'd')
call delete('Xfinddir1', 'd')
endfunc
" Test findfile({name} [, {path} [, {count}]])
@@ -34,7 +34,7 @@ func Test_findfile()
let save_dir = getcwd()
set shellslash
call CreateFiles()
cd Xdir1
cd Xfinddir1
e Xdir2/foo
" With ,, in path, findfile() searches in current directory.
@@ -83,34 +83,34 @@ func Test_findfile()
" Test upwards search.
cd Xdir2/Xdir3
call assert_equal('bar', findfile('bar', ';'))
call assert_match('.*/Xdir1/Xdir2/foo', findfile('foo', ';'))
call assert_match('.*/Xdir1/Xdir2/foo', findfile('foo', ';', 1))
call assert_match('.*/Xdir1/foo', findfile('foo', ';', 2))
call assert_match('.*/Xdir1/foo', findfile('foo', ';', 2))
call assert_match('.*/Xdir1/Xdir2/foo', findfile('foo', 'Xdir2;', 1))
call assert_match('.*/Xfinddir1/Xdir2/foo', findfile('foo', ';'))
call assert_match('.*/Xfinddir1/Xdir2/foo', findfile('foo', ';', 1))
call assert_match('.*/Xfinddir1/foo', findfile('foo', ';', 2))
call assert_match('.*/Xfinddir1/foo', findfile('foo', ';', 2))
call assert_match('.*/Xfinddir1/Xdir2/foo', findfile('foo', 'Xdir2;', 1))
call assert_equal('', findfile('foo', 'Xdir2;', 2))
" List l should have at least 2 values (possibly more if foo file
" happens to be found upwards above Xdir1).
" happens to be found upwards above Xfinddir1).
let l = findfile('foo', ';', -1)
call assert_match('.*/Xdir1/Xdir2/foo', l[0])
call assert_match('.*/Xdir1/foo', l[1])
call assert_match('.*/Xfinddir1/Xdir2/foo', l[0])
call assert_match('.*/Xfinddir1/foo', l[1])
" Test upwards search with stop-directory.
cd Xdir2
let l = findfile('bar', ';' . save_dir . '/Xdir1/Xdir2/', -1)
let l = findfile('bar', ';' . save_dir . '/Xfinddir1/Xdir2/', -1)
call assert_equal(1, len(l))
call assert_match('.*/Xdir1/Xdir2/Xdir3/bar', l[0])
call assert_match('.*/Xfinddir1/Xdir2/Xdir3/bar', l[0])
let l = findfile('bar', ';' . save_dir . '/Xdir1/', -1)
let l = findfile('bar', ';' . save_dir . '/Xfinddir1/', -1)
call assert_equal(2, len(l))
call assert_match('.*/Xdir1/Xdir2/Xdir3/bar', l[0])
call assert_match('.*/Xdir1/bar', l[1])
call assert_match('.*/Xfinddir1/Xdir2/Xdir3/bar', l[0])
call assert_match('.*/Xfinddir1/bar', l[1])
" Test combined downwards and upwards search from Xdir2/.
cd ../..
call assert_equal('Xdir3/bar', findfile('bar', '**;', 1))
call assert_match('.*/Xdir1/bar', findfile('bar', '**;', 2))
call assert_match('.*/Xfinddir1/bar', findfile('bar', '**;', 2))
bwipe!
call chdir(save_dir)
@@ -134,7 +134,7 @@ func Test_finddir()
let save_dir = getcwd()
set path=,,
call CreateFiles()
cd Xdir1
cd Xfinddir1
call assert_equal('Xdir2', finddir('Xdir2'))
call assert_equal('', 'Xdir3'->finddir())
@@ -157,17 +157,17 @@ func Test_finddir()
" Test upwards dir search.
cd Xdir2/Xdir3
call assert_match('.*/Xdir1', finddir('Xdir1', ';'))
call assert_match('.*/Xfinddir1', finddir('Xfinddir1', ';'))
" Test upwards search with stop-directory.
call assert_match('.*/Xdir1', finddir('Xdir1', ';' . save_dir . '/'))
call assert_equal('', finddir('Xdir1', ';' . save_dir . '/Xdir1/'))
call assert_match('.*/Xfinddir1', finddir('Xfinddir1', ';' . save_dir . '/'))
call assert_equal('', finddir('Xfinddir1', ';' . save_dir . '/Xfinddir1/'))
" Test combined downwards and upwards dir search from Xdir2/.
cd ..
call assert_match('.*/Xdir1', finddir('Xdir1', '**;', 1))
call assert_match('.*/Xfinddir1', finddir('Xfinddir1', '**;', 1))
call assert_equal('Xdir3/Xdir2', finddir('Xdir2', '**;', 1))
call assert_match('.*/Xdir1/Xdir2', finddir('Xdir2', '**;', 2))
call assert_match('.*/Xfinddir1/Xdir2', finddir('Xdir2', '**;', 2))
call assert_equal('Xdir3', finddir('Xdir3', '**;', 1))
call chdir(save_dir)
@@ -191,7 +191,7 @@ func Test_find_cmd()
let save_dir = getcwd()
set path=.,./**/*
call CreateFiles()
cd Xdir1
cd Xfinddir1
" Test for :find
find foo
+70 -70
View File
@@ -347,9 +347,9 @@ func Test_resolve_unix()
call delete('Xlink2')
call delete('Xlink3')
silent !ln -s -f Xdir//Xfile Xlink
call assert_equal('Xdir/Xfile', resolve('Xlink'))
call delete('Xlink')
silent !ln -s -f Xresolvedir//Xfile Xresolvelink
call assert_equal('Xresolvedir/Xfile', resolve('Xresolvelink'))
call delete('Xresolvelink')
silent !ln -s -f Xlink2/ Xlink1
call assert_equal('Xlink2', 'Xlink1'->resolve())
@@ -497,9 +497,9 @@ func Test_simplify()
call assert_equal('./file', simplify('dir/.././file'))
call assert_equal('../dir', simplify('./../dir'))
call assert_equal('..', simplify('../testdir/..'))
call mkdir('Xdir')
call assert_equal('.', simplify('Xdir/../.'))
call delete('Xdir', 'd')
call mkdir('Xsimpdir')
call assert_equal('.', simplify('Xsimpdir/../.'))
call delete('Xsimpdir', 'd')
call assert_fails('call simplify({->0})', 'E729:')
call assert_fails('call simplify([])', 'E730:')
@@ -1336,9 +1336,9 @@ func Test_filewritable()
call assert_equal(0, filewritable('doesnotexist'))
call mkdir('Xdir')
call assert_equal(2, filewritable('Xdir'))
call delete('Xdir', 'd')
call mkdir('Xwritedir')
call assert_equal(2, filewritable('Xwritedir'))
call delete('Xwritedir', 'd')
call delete('Xfilewritable')
bw!
@@ -1364,17 +1364,17 @@ func Test_Executable()
bwipe
" create "notepad.bat"
call mkdir('Xdir')
let notepadbat = fnamemodify('Xdir/notepad.bat', ':p')
call mkdir('Xnotedir')
let notepadbat = fnamemodify('Xnotedir/notepad.bat', ':p')
call writefile([], notepadbat)
new
" check that the path and the pathext order is valid
lcd Xdir
lcd Xnotedir
let [pathext, $PATHEXT] = [$PATHEXT, '.com;.exe;.bat;.cmd']
call assert_equal(notepadbat, exepath('notepad'))
let $PATHEXT = pathext
bwipe
eval 'Xdir'->delete('rf')
eval 'Xnotedir'->delete('rf')
elseif has('unix')
call assert_equal(1, 'cat'->executable())
call assert_equal(0, executable('nodogshere'))
@@ -2073,88 +2073,88 @@ func Test_platform_name()
endfunc
func Test_readdir()
call mkdir('Xdir')
call writefile([], 'Xdir/foo.txt')
call writefile([], 'Xdir/bar.txt')
call mkdir('Xdir/dir')
call mkdir('Xreaddir')
call writefile([], 'Xreaddir/foo.txt')
call writefile([], 'Xreaddir/bar.txt')
call mkdir('Xreaddir/dir')
" All results
let files = readdir('Xdir')
let files = readdir('Xreaddir')
call assert_equal(['bar.txt', 'dir', 'foo.txt'], sort(files))
" Only results containing "f"
let files = 'Xdir'->readdir({ x -> stridx(x, 'f') != -1 })
let files = 'Xreaddir'->readdir({ x -> stridx(x, 'f') != -1 })
call assert_equal(['foo.txt'], sort(files))
" Only .txt files
let files = readdir('Xdir', { x -> x =~ '.txt$' })
let files = readdir('Xreaddir', { x -> x =~ '.txt$' })
call assert_equal(['bar.txt', 'foo.txt'], sort(files))
" Only .txt files with string
let files = readdir('Xdir', 'v:val =~ ".txt$"')
let files = readdir('Xreaddir', 'v:val =~ ".txt$"')
call assert_equal(['bar.txt', 'foo.txt'], sort(files))
" Limit to 1 result.
let l = []
let files = readdir('Xdir', {x -> len(add(l, x)) == 2 ? -1 : 1})
let files = readdir('Xreaddir', {x -> len(add(l, x)) == 2 ? -1 : 1})
call assert_equal(1, len(files))
" Nested readdir() must not crash
let files = readdir('Xdir', 'readdir("Xdir", "1") != []')
let files = readdir('Xreaddir', 'readdir("Xreaddir", "1") != []')
call sort(files)->assert_equal(['bar.txt', 'dir', 'foo.txt'])
eval 'Xdir'->delete('rf')
eval 'Xreaddir'->delete('rf')
endfunc
func Test_readdirex()
call mkdir('Xdir')
call writefile(['foo'], 'Xdir/foo.txt')
call writefile(['barbar'], 'Xdir/bar.txt')
call mkdir('Xdir/dir')
call mkdir('Xexdir')
call writefile(['foo'], 'Xexdir/foo.txt')
call writefile(['barbar'], 'Xexdir/bar.txt')
call mkdir('Xexdir/dir')
" All results
let files = readdirex('Xdir')->map({-> v:val.name})
let files = readdirex('Xexdir')->map({-> v:val.name})
call assert_equal(['bar.txt', 'dir', 'foo.txt'], sort(files))
let sizes = readdirex('Xdir')->map({-> v:val.size})
let sizes = readdirex('Xexdir')->map({-> v:val.size})
call assert_equal([0, 4, 7], sort(sizes))
" Only results containing "f"
let files = 'Xdir'->readdirex({ e -> stridx(e.name, 'f') != -1 })
let files = 'Xexdir'->readdirex({ e -> stridx(e.name, 'f') != -1 })
\ ->map({-> v:val.name})
call assert_equal(['foo.txt'], sort(files))
" Only .txt files
let files = readdirex('Xdir', { e -> e.name =~ '.txt$' })
let files = readdirex('Xexdir', { e -> e.name =~ '.txt$' })
\ ->map({-> v:val.name})
call assert_equal(['bar.txt', 'foo.txt'], sort(files))
" Only .txt files with string
let files = readdirex('Xdir', 'v:val.name =~ ".txt$"')
let files = readdirex('Xexdir', 'v:val.name =~ ".txt$"')
\ ->map({-> v:val.name})
call assert_equal(['bar.txt', 'foo.txt'], sort(files))
" Limit to 1 result.
let l = []
let files = readdirex('Xdir', {e -> len(add(l, e.name)) == 2 ? -1 : 1})
let files = readdirex('Xexdir', {e -> len(add(l, e.name)) == 2 ? -1 : 1})
\ ->map({-> v:val.name})
call assert_equal(1, len(files))
" Nested readdirex() must not crash
let files = readdirex('Xdir', 'readdirex("Xdir", "1") != []')
let files = readdirex('Xexdir', 'readdirex("Xexdir", "1") != []')
\ ->map({-> v:val.name})
call sort(files)->assert_equal(['bar.txt', 'dir', 'foo.txt'])
" report broken link correctly
if has("unix")
call writefile([], 'Xdir/abc.txt')
call system("ln -s Xdir/abc.txt Xdir/link")
call delete('Xdir/abc.txt')
let files = readdirex('Xdir', 'readdirex("Xdir", "1") != []')
call writefile([], 'Xexdir/abc.txt')
call system("ln -s Xexdir/abc.txt Xexdir/link")
call delete('Xexdir/abc.txt')
let files = readdirex('Xexdir', 'readdirex("Xexdir", "1") != []')
\ ->map({-> v:val.name .. '_' .. v:val.type})
call sort(files)->assert_equal(
\ ['bar.txt_file', 'dir_dir', 'foo.txt_file', 'link_link'])
endif
eval 'Xdir'->delete('rf')
eval 'Xexdir'->delete('rf')
call assert_fails('call readdirex("doesnotexist")', 'E484:')
endfunc
@@ -2166,34 +2166,34 @@ func Test_readdirex_sort()
throw 'Skipped: Test_readdirex_sort on systems that do not allow this using the default filesystem'
endif
let _collate = v:collate
call mkdir('Xdir2')
call writefile(['1'], 'Xdir2/README.txt')
call writefile(['2'], 'Xdir2/Readme.txt')
call writefile(['3'], 'Xdir2/readme.txt')
call mkdir('Xsortdir2')
call writefile(['1'], 'Xsortdir2/README.txt')
call writefile(['2'], 'Xsortdir2/Readme.txt')
call writefile(['3'], 'Xsortdir2/readme.txt')
" 1) default
let files = readdirex('Xdir2')->map({-> v:val.name})
let files = readdirex('Xsortdir2')->map({-> v:val.name})
let default = copy(files)
call assert_equal(['README.txt', 'Readme.txt', 'readme.txt'], files, 'sort using default')
" 2) no sorting
let files = readdirex('Xdir2', 1, #{sort: 'none'})->map({-> v:val.name})
let files = readdirex('Xsortdir2', 1, #{sort: 'none'})->map({-> v:val.name})
let unsorted = copy(files)
call assert_equal(['README.txt', 'Readme.txt', 'readme.txt'], sort(files), 'unsorted')
call assert_fails("call readdirex('Xdir2', 1, #{slort: 'none'})", 'E857: Dictionary key "sort" required')
call assert_fails("call readdirex('Xsortdir2', 1, #{slort: 'none'})", 'E857: Dictionary key "sort" required')
" 3) sort by case (same as default)
let files = readdirex('Xdir2', 1, #{sort: 'case'})->map({-> v:val.name})
let files = readdirex('Xsortdir2', 1, #{sort: 'case'})->map({-> v:val.name})
call assert_equal(default, files, 'sort by case')
" 4) sort by ignoring case
let files = readdirex('Xdir2', 1, #{sort: 'icase'})->map({-> v:val.name})
let files = readdirex('Xsortdir2', 1, #{sort: 'icase'})->map({-> v:val.name})
call assert_equal(unsorted->sort('i'), files, 'sort by icase')
" 5) Default Collation
let collate = v:collate
lang collate C
let files = readdirex('Xdir2', 1, #{sort: 'collate'})->map({-> v:val.name})
let files = readdirex('Xsortdir2', 1, #{sort: 'collate'})->map({-> v:val.name})
call assert_equal(['README.txt', 'Readme.txt', 'readme.txt'], files, 'sort by C collation')
" 6) Collation de_DE
@@ -2201,20 +2201,20 @@ func Test_readdirex_sort()
" available
try
lang collate de_DE
let files = readdirex('Xdir2', 1, #{sort: 'collate'})->map({-> v:val.name})
let files = readdirex('Xsortdir2', 1, #{sort: 'collate'})->map({-> v:val.name})
call assert_equal(['readme.txt', 'Readme.txt', 'README.txt'], files, 'sort by de_DE collation')
catch
throw 'Skipped: de_DE collation is not available'
finally
exe 'lang collate' collate
eval 'Xdir2'->delete('rf')
eval 'Xsortdir2'->delete('rf')
endtry
endfunc
func Test_readdir_sort()
" some more cases for testing sorting for readdirex
let dir = 'Xdir3'
let dir = 'Xsortdir3'
call mkdir(dir)
call writefile(['1'], dir .. '/README.txt')
call writefile(['2'], dir .. '/Readm.txt')
@@ -2259,26 +2259,26 @@ func Test_readdir_sort()
endfunc
func Test_delete_rf()
call mkdir('Xdir')
call writefile([], 'Xdir/foo.txt')
call writefile([], 'Xdir/bar.txt')
call mkdir('Xdir/[a-1]') " issue #696
call writefile([], 'Xdir/[a-1]/foo.txt')
call writefile([], 'Xdir/[a-1]/bar.txt')
call assert_true(filereadable('Xdir/foo.txt'))
call assert_true('Xdir/[a-1]/foo.txt'->filereadable())
call mkdir('Xrfdir')
call writefile([], 'Xrfdir/foo.txt')
call writefile([], 'Xrfdir/bar.txt')
call mkdir('Xrfdir/[a-1]') " issue #696
call writefile([], 'Xrfdir/[a-1]/foo.txt')
call writefile([], 'Xrfdir/[a-1]/bar.txt')
call assert_true(filereadable('Xrfdir/foo.txt'))
call assert_true('Xrfdir/[a-1]/foo.txt'->filereadable())
call assert_equal(0, delete('Xdir', 'rf'))
call assert_false(filereadable('Xdir/foo.txt'))
call assert_false(filereadable('Xdir/[a-1]/foo.txt'))
call assert_equal(0, delete('Xrfdir', 'rf'))
call assert_false(filereadable('Xrfdir/foo.txt'))
call assert_false(filereadable('Xrfdir/[a-1]/foo.txt'))
if has('unix')
call mkdir('Xdir/Xdir2', 'p')
silent !chmod 555 Xdir
call assert_equal(-1, delete('Xdir/Xdir2', 'rf'))
call assert_equal(-1, delete('Xdir', 'rf'))
silent !chmod 755 Xdir
call assert_equal(0, delete('Xdir', 'rf'))
call mkdir('Xrfdir/Xdir2', 'p')
silent !chmod 555 Xrfdir
call assert_equal(-1, delete('Xrfdir/Xdir2', 'rf'))
call assert_equal(-1, delete('Xrfdir', 'rf'))
silent !chmod 755 Xrfdir
call assert_equal(0, delete('Xrfdir', 'rf'))
endif
endfunc
+28 -28
View File
@@ -40,9 +40,9 @@ func SetUp()
eval 'Xtopdir'->mkdir()
cd Xtopdir
let g:topdir = getcwd()
call mkdir('Xdir1')
call mkdir('Xdir2')
call mkdir('Xdir3')
call mkdir('Xcwdir1')
call mkdir('Xcwdir2')
call mkdir('Xcwdir3')
endfunction
let g:cwd=getcwd()
@@ -57,23 +57,23 @@ function Test_GetCwd()
new b
new c
3wincmd w
lcd Xdir1
call assert_equal("a Xdir1 1", GetCwdInfo(0, 0))
lcd Xcwdir1
call assert_equal("a Xcwdir1 1", GetCwdInfo(0, 0))
call assert_equal(g:topdir, getcwd(-1))
wincmd W
call assert_equal("b Xtopdir 0", GetCwdInfo(0, 0))
call assert_equal(g:topdir, getcwd(-1))
wincmd W
lcd Xdir3
call assert_equal("c Xdir3 1", GetCwdInfo(0, 0))
call assert_equal("a Xdir1 1", GetCwdInfo(bufwinnr("a"), 0))
lcd Xcwdir3
call assert_equal("c Xcwdir3 1", GetCwdInfo(0, 0))
call assert_equal("a Xcwdir1 1", GetCwdInfo(bufwinnr("a"), 0))
call assert_equal("b Xtopdir 0", GetCwdInfo(bufwinnr("b"), 0))
call assert_equal("c Xdir3 1", GetCwdInfo(bufwinnr("c"), 0))
call assert_equal("c Xcwdir3 1", GetCwdInfo(bufwinnr("c"), 0))
call assert_equal(g:topdir, getcwd(-1))
wincmd W
call assert_equal("a Xdir1 1", GetCwdInfo(bufwinnr("a"), tabpagenr()))
call assert_equal("a Xcwdir1 1", GetCwdInfo(bufwinnr("a"), tabpagenr()))
call assert_equal("b Xtopdir 0", GetCwdInfo(bufwinnr("b"), tabpagenr()))
call assert_equal("c Xdir3 1", GetCwdInfo(bufwinnr("c"), tabpagenr()))
call assert_equal("c Xcwdir3 1", GetCwdInfo(bufwinnr("c"), tabpagenr()))
call assert_equal(g:topdir, getcwd(-1))
tabnew x
@@ -83,21 +83,21 @@ function Test_GetCwd()
call assert_equal("x Xtopdir 0", GetCwdInfo(0, 0))
call assert_equal(g:topdir, getcwd(-1))
wincmd W
lcd Xdir2
call assert_equal("y Xdir2 1", GetCwdInfo(0, 0))
lcd Xcwdir2
call assert_equal("y Xcwdir2 1", GetCwdInfo(0, 0))
call assert_equal(g:topdir, getcwd(-1))
wincmd W
lcd Xdir3
call assert_equal("z Xdir3 1", GetCwdInfo(0, 0))
lcd Xcwdir3
call assert_equal("z Xcwdir3 1", GetCwdInfo(0, 0))
call assert_equal("x Xtopdir 0", GetCwdInfo(bufwinnr("x"), 0))
call assert_equal("y Xdir2 1", GetCwdInfo(bufwinnr("y"), 0))
call assert_equal("z Xdir3 1", GetCwdInfo(bufwinnr("z"), 0))
call assert_equal("y Xcwdir2 1", GetCwdInfo(bufwinnr("y"), 0))
call assert_equal("z Xcwdir3 1", GetCwdInfo(bufwinnr("z"), 0))
call assert_equal(g:topdir, getcwd(-1))
let tp_nr = tabpagenr()
tabrewind
call assert_equal("x Xtopdir 0", GetCwdInfo(3, tp_nr))
call assert_equal("y Xdir2 1", GetCwdInfo(2, tp_nr))
call assert_equal("z Xdir3 1", GetCwdInfo(1, tp_nr))
call assert_equal("y Xcwdir2 1", GetCwdInfo(2, tp_nr))
call assert_equal("z Xcwdir3 1", GetCwdInfo(1, tp_nr))
call assert_equal(g:topdir, getcwd(-1))
" Non existing windows and tab pages
call assert_equal('', getcwd(100))
@@ -241,24 +241,24 @@ function Test_Tab_Local_Cwd()
" Change the global directory for the first tab page
tabrewind | 1wincmd w
cd ../Xdir1
call assert_equal("a Xdir1 0", GetCwdInfo(1, 1))
call assert_equal("b Xdir1 0", GetCwdInfo(2, 1))
cd ../Xcwdir1
call assert_equal("a Xcwdir1 0", GetCwdInfo(1, 1))
call assert_equal("b Xcwdir1 0", GetCwdInfo(2, 1))
call assert_equal("m Xtabdir1 2", GetCwdInfo(1, 2))
call assert_equal("n Xwindir2 1", GetCwdInfo(2, 2))
" Change the global directory for the second tab page
tabnext | 1wincmd w
cd ../Xdir3
call assert_equal("m Xdir3 0", GetCwdInfo(1, 2))
cd ../Xcwdir3
call assert_equal("m Xcwdir3 0", GetCwdInfo(1, 2))
call assert_equal("n Xwindir2 1", GetCwdInfo(2, 2))
call assert_equal("o Xdir3 0", GetCwdInfo(3, 2))
call assert_equal("o Xcwdir3 0", GetCwdInfo(3, 2))
" Change the tab-local directory for the third tab page
tabnext | 1wincmd w
cd ../Xdir1
call assert_equal("x Xdir1 0", GetCwdInfo(1, 3))
call assert_equal("y Xdir1 0", GetCwdInfo(2, 3))
cd ../Xcwdir1
call assert_equal("x Xcwdir1 0", GetCwdInfo(1, 3))
call assert_equal("y Xcwdir1 0", GetCwdInfo(2, 3))
call assert_equal("z Xwindir3 1", GetCwdInfo(3, 3))
enew | only | tabonly
+12 -12
View File
@@ -1407,36 +1407,36 @@ func Test_gui_drop_files()
%argdelete
" pressing shift when dropping files should change directory
let save_cwd = getcwd()
call mkdir('Xdir1')
call writefile([], 'Xdir1/Xfile1')
call writefile([], 'Xdir1/Xfile2')
let d = #{files: ['Xdir1/Xfile1', 'Xdir1/Xfile2'], row: 1, col: 1,
call mkdir('Xdropdir1')
call writefile([], 'Xdropdir1/Xfile1')
call writefile([], 'Xdropdir1/Xfile2')
let d = #{files: ['Xdropdir1/Xfile1', 'Xdropdir1/Xfile2'], row: 1, col: 1,
\ modifiers: 0x4}
call test_gui_event('dropfiles', d)
call assert_equal('Xdir1', fnamemodify(getcwd(), ':t'))
call assert_equal('Xdropdir1', fnamemodify(getcwd(), ':t'))
call assert_equal('Xfile1', @%)
call chdir(save_cwd)
" pressing shift when dropping directory and files should change directory
let d = #{files: ['Xdir1', 'Xdir1/Xfile2'], row: 1, col: 1, modifiers: 0x4}
let d = #{files: ['Xdropdir1', 'Xdropdir1/Xfile2'], row: 1, col: 1, modifiers: 0x4}
call test_gui_event('dropfiles', d)
call assert_equal('Xdir1', fnamemodify(getcwd(), ':t'))
call assert_equal('Xdir1', fnamemodify(@%, ':t'))
call assert_equal('Xdropdir1', fnamemodify(getcwd(), ':t'))
call assert_equal('Xdropdir1', fnamemodify(@%, ':t'))
call chdir(save_cwd)
%bw!
%argdelete
" dropping a directory should edit it
let d = #{files: ['Xdir1'], row: 1, col: 1, modifiers: 0}
let d = #{files: ['Xdropdir1'], row: 1, col: 1, modifiers: 0}
call test_gui_event('dropfiles', d)
call assert_equal('Xdir1', @%)
call assert_equal('Xdropdir1', @%)
%bw!
%argdelete
" dropping only a directory name with Shift should ignore it
let d = #{files: ['Xdir1'], row: 1, col: 1, modifiers: 0x4}
let d = #{files: ['Xdropdir1'], row: 1, col: 1, modifiers: 0x4}
call test_gui_event('dropfiles', d)
call assert_equal('', @%)
%bw!
%argdelete
call delete('Xdir1', 'rf')
call delete('Xdropdir1', 'rf')
" drop files in the command line. The GUI drop files adds the file names to
" the low level input buffer. So need to use a cmdline map and feedkeys()
+24 -24
View File
@@ -129,30 +129,30 @@ endfunc
" Test for the :helptags command
" NOTE: if you run tests as root this will fail. Don't run tests as root!
func Test_helptag_cmd()
call mkdir('Xdir/a/doc', 'p')
call mkdir('Xtagdir/a/doc', 'p')
" No help file to process in the directory
call assert_fails('helptags Xdir', 'E151:')
call assert_fails('helptags Xtagdir', 'E151:')
call writefile([], 'Xdir/a/doc/sample.txt')
call writefile([], 'Xtagdir/a/doc/sample.txt')
" Test for ++t argument
helptags ++t Xdir
call assert_equal(["help-tags\ttags\t1"], readfile('Xdir/tags'))
call delete('Xdir/tags')
helptags ++t Xtagdir
call assert_equal(["help-tags\ttags\t1"], readfile('Xtagdir/tags'))
call delete('Xtagdir/tags')
" Test parsing tags
call writefile(['*tag1*', 'Example: >', ' *notag*', 'Example end: *tag2*'],
\ 'Xdir/a/doc/sample.txt')
helptags Xdir
\ 'Xtagdir/a/doc/sample.txt')
helptags Xtagdir
call assert_equal(["tag1\ta/doc/sample.txt\t/*tag1*",
\ "tag2\ta/doc/sample.txt\t/*tag2*"], readfile('Xdir/tags'))
\ "tag2\ta/doc/sample.txt\t/*tag2*"], readfile('Xtagdir/tags'))
" Duplicate tags in the help file
call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xdir/a/doc/sample.txt')
call assert_fails('helptags Xdir', 'E154:')
call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xtagdir/a/doc/sample.txt')
call assert_fails('helptags Xtagdir', 'E154:')
call delete('Xdir', 'rf')
call delete('Xtagdir', 'rf')
endfunc
func Test_helptag_cmd_readonly()
@@ -160,25 +160,25 @@ func Test_helptag_cmd_readonly()
CheckNotRoot
" Read-only tags file
call mkdir('Xdir/doc', 'p')
call writefile([''], 'Xdir/doc/tags')
call writefile([], 'Xdir/doc/sample.txt')
call setfperm('Xdir/doc/tags', 'r-xr--r--')
call assert_fails('helptags Xdir/doc', 'E152:', getfperm('Xdir/doc/tags'))
call mkdir('Xrodir/doc', 'p')
call writefile([''], 'Xrodir/doc/tags')
call writefile([], 'Xrodir/doc/sample.txt')
call setfperm('Xrodir/doc/tags', 'r-xr--r--')
call assert_fails('helptags Xrodir/doc', 'E152:', getfperm('Xrodir/doc/tags'))
let rtp = &rtp
let &rtp = 'Xdir'
let &rtp = 'Xrodir'
helptags ALL
let &rtp = rtp
call delete('Xdir/doc/tags')
call delete('Xrodir/doc/tags')
" No permission to read the help file
call mkdir('Xdir/b/doc', 'p')
call writefile([], 'Xdir/b/doc/sample.txt')
call setfperm('Xdir/b/doc/sample.txt', '-w-------')
call assert_fails('helptags Xdir', 'E153:', getfperm('Xdir/b/doc/sample.txt'))
call delete('Xdir', 'rf')
call mkdir('Xrodir/b/doc', 'p')
call writefile([], 'Xrodir/b/doc/sample.txt')
call setfperm('Xrodir/b/doc/sample.txt', '-w-------')
call assert_fails('helptags Xrodir', 'E153:', getfperm('Xrodir/b/doc/sample.txt'))
call delete('Xrodir', 'rf')
endfunc
" Test for setting the 'helpheight' option in the help window
+17 -17
View File
@@ -9,8 +9,8 @@ func Test_ins_complete()
edit test_ins_complete.vim
" The files in the current directory interferes with the files
" used by this test. So use a separate directory for the test.
call mkdir('Xdir')
cd Xdir
call mkdir('Xcpldir')
cd Xcpldir
set ff=unix
call writefile(["test11\t36Gepeto\t/Tag/",
@@ -105,7 +105,7 @@ func Test_ins_complete()
call delete('Xtestdata')
set cpt& cot& def& tags& tagbsearch& hidden&
cd ..
call delete('Xdir', 'rf')
call delete('Xcpldir', 'rf')
endfunc
func Test_ins_complete_invalid_byte()
@@ -433,7 +433,7 @@ endfunc
func Test_ins_completeslash()
CheckMSWindows
call mkdir('Xdir')
call mkdir('Xcpldir')
let orig_shellslash = &shellslash
set cpt&
new
@@ -441,32 +441,32 @@ func Test_ins_completeslash()
set noshellslash
set completeslash=
exe "normal oXd\<C-X>\<C-F>"
call assert_equal('Xdir\', getline('.'))
exe "normal oXcp\<C-X>\<C-F>"
call assert_equal('Xcpldir\', getline('.'))
set completeslash=backslash
exe "normal oXd\<C-X>\<C-F>"
call assert_equal('Xdir\', getline('.'))
exe "normal oXcp\<C-X>\<C-F>"
call assert_equal('Xcpldir\', getline('.'))
set completeslash=slash
exe "normal oXd\<C-X>\<C-F>"
call assert_equal('Xdir/', getline('.'))
exe "normal oXcp\<C-X>\<C-F>"
call assert_equal('Xcpldir/', getline('.'))
set shellslash
set completeslash=
exe "normal oXd\<C-X>\<C-F>"
call assert_equal('Xdir/', getline('.'))
exe "normal oXcp\<C-X>\<C-F>"
call assert_equal('Xcpldir/', getline('.'))
set completeslash=backslash
exe "normal oXd\<C-X>\<C-F>"
call assert_equal('Xdir\', getline('.'))
exe "normal oXcp\<C-X>\<C-F>"
call assert_equal('Xcpldir\', getline('.'))
set completeslash=slash
exe "normal oXd\<C-X>\<C-F>"
call assert_equal('Xdir/', getline('.'))
exe "normal oXcp\<C-X>\<C-F>"
call assert_equal('Xcpldir/', getline('.'))
%bw!
call delete('Xdir', 'rf')
call delete('Xcpldir', 'rf')
set noshellslash
set completeslash=slash
+25
View File
@@ -537,5 +537,30 @@ func Test_cmdheight_zero_shell()
set cmdheight&
endfunc
func Test_echowindow()
CheckScreendump
let lines =<< trim END
call setline(1, 'some text')
func ShowMessage(arg)
echowindow a:arg
endfunc
echowindow 'first line'
END
call writefile(lines, 'XtestEchowindow')
let buf = RunVimInTerminal('-S XtestEchowindow', #{rows: 8})
call VerifyScreenDump(buf, 'Test_echowindow_1', {})
call term_sendkeys(buf, ":call ShowMessage('second line')\<CR>")
call VerifyScreenDump(buf, 'Test_echowindow_2', {})
call term_sendkeys(buf, ":call popup_clear()\<CR>")
call VerifyScreenDump(buf, 'Test_echowindow_3', {})
" clean up
call StopVimInTerminal(buf)
call delete('XtestEchowindow')
endfunc
" vim: shiftwidth=2 sts=2 expandtab
+6 -6
View File
@@ -3,7 +3,7 @@
source check.vim
func SetUp()
let s:topdir = getcwd() . '/Xdir'
let s:topdir = getcwd() . '/Xppdir'
exe 'set packpath=' . s:topdir
let s:plugdir = s:topdir . '/pack/mine/opt/mytest'
endfunc
@@ -51,9 +51,9 @@ func Test_packadd()
call assert_equal(77, g:plugin_also_works)
call assert_equal(17, g:ftdetect_works)
call assert_true(len(&rtp) > len(rtp))
call assert_match('/testdir/Xdir/pack/mine/opt/mytest\($\|,\)', &rtp)
call assert_match('/testdir/Xppdir/pack/mine/opt/mytest\($\|,\)', &rtp)
let new_after = match(&rtp, '/testdir/Xdir/pack/mine/opt/mytest/after,')
let new_after = match(&rtp, '/testdir/Xppdir/pack/mine/opt/mytest/after,')
let forwarded = substitute(first_after_entry, '\\', '[/\\\\]', 'g')
let old_after = match(&rtp, ',' . forwarded . '\>')
call assert_true(new_after > 0, 'rtp is ' . &rtp)
@@ -67,7 +67,7 @@ func Test_packadd()
" Check the path of 'myte' is added
call assert_true(len(&rtp) > len(rtp))
call assert_match('/testdir/Xdir/pack/mine/opt/myte\($\|,\)', &rtp)
call assert_match('/testdir/Xppdir/pack/mine/opt/myte\($\|,\)', &rtp)
" Check exception
call assert_fails("packadd directorynotfound", 'E919:')
@@ -89,7 +89,7 @@ func Test_packadd_start()
call assert_equal(24, g:plugin_works)
call assert_true(len(&rtp) > len(rtp))
call assert_match('/testdir/Xdir/pack/mine/start/other\($\|,\)', &rtp)
call assert_match('/testdir/Xppdir/pack/mine/start/other\($\|,\)', &rtp)
endfunc
func Test_packadd_noload()
@@ -106,7 +106,7 @@ func Test_packadd_noload()
packadd! mytest
call assert_true(len(&rtp) > len(rtp))
call assert_match('testdir/Xdir/pack/mine/opt/mytest\($\|,\)', &rtp)
call assert_match('testdir/Xppdir/pack/mine/opt/mytest\($\|,\)', &rtp)
call assert_equal(0, g:plugin_works)
" check the path is not added twice
+22 -6
View File
@@ -4107,6 +4107,22 @@ func Xgetlist_empty_tests(cchar)
endif
endfunc
func Test_empty_list_quickfixtextfunc()
" This was crashing. Can only reproduce by running it in a separate Vim
" instance.
let lines =<< trim END
func s:Func(o)
cgetexpr '0'
endfunc
cope
let &quickfixtextfunc = 's:Func'
cgetfile [ex
END
call writefile(lines, 'Xquickfixtextfunc')
call RunVim([], [], '-e -s -S Xquickfixtextfunc -c qa')
call delete('Xquickfixtextfunc')
endfunc
func Test_getqflist()
call Xgetlist_empty_tests('c')
call Xgetlist_empty_tests('l')
@@ -4374,7 +4390,7 @@ func Xvimgrep_autocmd_cd(cchar)
autocmd BufRead * silent cd %:p:h
augroup END
10Xvimgrep /vim/ Xdir/**
10Xvimgrep /vim/ Xgrepdir/**
let l = g:Xgetlist()
call assert_equal('f1.txt', bufname(l[0].bufnr))
call assert_equal('f2.txt', fnamemodify(bufname(l[2].bufnr), ':t'))
@@ -4387,14 +4403,14 @@ func Xvimgrep_autocmd_cd(cchar)
endfunc
func Test_vimgrep_autocmd_cd()
call mkdir('Xdir/a', 'p')
call mkdir('Xdir/b', 'p')
call writefile(['a_L1_vim', 'a_L2_vim'], 'Xdir/a/f1.txt')
call writefile(['b_L1_vim', 'b_L2_vim'], 'Xdir/b/f2.txt')
call mkdir('Xgrepdir/a', 'p')
call mkdir('Xgrepdir/b', 'p')
call writefile(['a_L1_vim', 'a_L2_vim'], 'Xgrepdir/a/f1.txt')
call writefile(['b_L1_vim', 'b_L2_vim'], 'Xgrepdir/b/f2.txt')
call Xvimgrep_autocmd_cd('c')
call Xvimgrep_autocmd_cd('l')
%bwipe
call delete('Xdir', 'rf')
call delete('Xgrepdir', 'rf')
endfunc
" The following test used to crash Vim
+10 -10
View File
@@ -1066,13 +1066,13 @@ func Test_exrc()
call writefile(v:errors, 'Xtestout')
qall
[CODE]
call mkdir('Xdir')
call writefile(['let exrc_found=37'], 'Xdir/.exrc')
call writefile(after, 'Xdir/Xafter')
let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "cd Xdir" --cmd "set enc=utf8 exrc secure"'
call mkdir('Xrcdir')
call writefile(['let exrc_found=37'], 'Xrcdir/.exrc')
call writefile(after, 'Xrcdir/Xafter')
let cmd = GetVimProg() . ' --not-a-term -S Xafter --cmd "cd Xrcdir" --cmd "set enc=utf8 exrc secure"'
exe "silent !" . cmd
call assert_equal([], readfile('Xdir/Xtestout'))
call delete('Xdir', 'rf')
call assert_equal([], readfile('Xrcdir/Xtestout'))
call delete('Xrcdir', 'rf')
endfunc
" Test for starting Vim with a non-terminal as input/output
@@ -1127,10 +1127,10 @@ func Test_w_arg()
" Test for failing to open the script output file. This test works only when
" the language is English.
if v:lang == "C" || v:lang =~ '^[Ee]n'
call mkdir("Xdir")
let m = system(GetVimCommand() .. " -w Xdir")
call assert_equal("Cannot open for script output: \"Xdir\"\n", m)
call delete("Xdir", 'rf')
call mkdir("Xargdir")
let m = system(GetVimCommand() .. " -w Xargdir")
call assert_equal("Cannot open for script output: \"Xargdir\"\n", m)
call delete("Xargdir", 'rf')
endif
" A number argument sets the 'window' option
+4 -4
View File
@@ -630,12 +630,12 @@ func Test_terminal_cwd()
CheckExecutable pwd
let cmd = 'pwd'
endif
call mkdir('Xdir')
let buf = term_start(cmd, {'cwd': 'Xdir'})
call WaitForAssert({-> assert_equal('Xdir', fnamemodify(getline(1), ":t"))})
call mkdir('Xtermdir')
let buf = term_start(cmd, {'cwd': 'Xtermdir'})
call WaitForAssert({-> assert_equal('Xtermdir', fnamemodify(getline(1), ":t"))})
exe buf . 'bwipe'
call delete('Xdir', 'rf')
call delete('Xtermdir', 'rf')
endfunc
func Test_terminal_cwd_failure()
+4 -4
View File
@@ -315,14 +315,14 @@ def s:ScriptFuncPush()
enddef
def Test_disassemble_push()
mkdir('Xdir/autoload', 'p')
mkdir('Xdisdir/autoload', 'p')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xdisdir'
var lines =<< trim END
vim9script
END
writefile(lines, 'Xdir/autoload/autoscript.vim')
writefile(lines, 'Xdisdir/autoload/autoscript.vim')
lines =<< trim END
vim9script
@@ -342,7 +342,7 @@ def Test_disassemble_push()
END
v9.CheckScriptSuccess(lines)
delete('Xdir', 'rf')
delete('Xdisdir', 'rf')
&rtp = save_rtp
enddef
+12 -12
View File
@@ -41,7 +41,7 @@ def TestCompilingError()
enddef
def TestCompilingErrorInTry()
var dir = 'Xdir/autoload'
var dir = 'Xcompdir/autoload'
mkdir(dir, 'p')
var lines =<< trim END
@@ -61,7 +61,7 @@ def TestCompilingErrorInTry()
catch /nothing/
endtry
END
lines[1] = 'set rtp=' .. getcwd() .. '/Xdir'
lines[1] = 'set rtp=' .. getcwd() .. '/Xcompdir'
writefile(lines, 'XTest_compile_error')
var buf = g:RunVimInTerminal('-S XTest_compile_error', {rows: 10, wait_for_ruler: 0})
@@ -71,7 +71,7 @@ def TestCompilingErrorInTry()
# clean up
g:StopVimInTerminal(buf)
delete('XTest_compile_error')
delete('Xdir', 'rf')
delete('Xcompdir', 'rf')
enddef
def Test_comment_error()
@@ -170,7 +170,7 @@ def Test_wrong_function_name()
enddef
def Test_autoload_name_mismatch()
var dir = 'Xdir/autoload'
var dir = 'Xnamedir/autoload'
mkdir(dir, 'p')
var lines =<< trim END
@@ -183,18 +183,18 @@ def Test_autoload_name_mismatch()
writefile(lines, dir .. '/script.vim')
var save_rtp = &rtp
exe 'set rtp=' .. getcwd() .. '/Xdir'
exe 'set rtp=' .. getcwd() .. '/Xnamedir'
lines =<< trim END
call script#Function()
END
v9.CheckScriptFailure(lines, 'E117:', 1)
&rtp = save_rtp
delete(dir, 'rf')
delete('Xnamdir', 'rf')
enddef
def Test_autoload_names()
var dir = 'Xdir/autoload'
var dir = 'Xandir/autoload'
mkdir(dir, 'p')
var lines =<< trim END
@@ -206,7 +206,7 @@ def Test_autoload_names()
writefile(lines, dir .. '/foobar.vim')
var save_rtp = &rtp
exe 'set rtp=' .. getcwd() .. '/Xdir'
exe 'set rtp=' .. getcwd() .. '/Xandir'
lines =<< trim END
assert_equal('yes', foobar#function())
@@ -218,11 +218,11 @@ def Test_autoload_names()
v9.CheckDefAndScriptSuccess(lines)
&rtp = save_rtp
delete(dir, 'rf')
delete('Xandir', 'rf')
enddef
def Test_autoload_error_in_script()
var dir = 'Xdir/autoload'
var dir = 'Xaedir/autoload'
mkdir(dir, 'p')
var lines =<< trim END
@@ -234,7 +234,7 @@ def Test_autoload_error_in_script()
writefile(lines, dir .. '/scripterror.vim')
var save_rtp = &rtp
exe 'set rtp=' .. getcwd() .. '/Xdir'
exe 'set rtp=' .. getcwd() .. '/Xaedir'
g:called_function = 'no'
# The error in the autoload script cannot be checked with assert_fails(), use
@@ -264,7 +264,7 @@ def Test_autoload_error_in_script()
assert_equal('yes', g:called_function)
&rtp = save_rtp
delete(dir, 'rf')
delete('Xaedir', 'rf')
enddef
def s:CallRecursive(n: number): number
+103 -103
View File
@@ -766,10 +766,10 @@ def Test_use_autoload_import_in_mapping()
g:result = 49
enddef
END
mkdir('Xdir/autoload', 'p')
writefile(lines, 'Xdir/autoload/XautoloadExport.vim')
mkdir('Ximpdir/autoload', 'p')
writefile(lines, 'Ximpdir/autoload/XautoloadExport.vim')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Ximpdir'
lines =<< trim END
vim9script
@@ -786,7 +786,7 @@ def Test_use_autoload_import_in_mapping()
unlet g:result
delete('Xmapscript.vim')
nunmap <F3>
delete('Xdir', 'rf')
delete('Ximpdir', 'rf')
&rtp = save_rtp
enddef
@@ -838,9 +838,9 @@ def Test_use_import_with_funcref_in_command_completion()
enddef
def Test_use_autoload_import_in_insert_completion()
mkdir('Xdir/autoload', 'p')
mkdir('Xinsdir/autoload', 'p')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xinsdir'
var lines =<< trim END
vim9script
@@ -857,7 +857,7 @@ def Test_use_autoload_import_in_insert_completion()
enddef
g:completion_loaded = 'yes'
END
writefile(lines, 'Xdir/autoload/completion.vim')
writefile(lines, 'Xinsdir/autoload/completion.vim')
new
lines =<< trim END
@@ -874,22 +874,22 @@ def Test_use_autoload_import_in_insert_completion()
set thesaurusfunc=
bwipe!
delete('Xdir', 'rf')
delete('Xinsdir', 'rf')
&rtp = save_rtp
enddef
def Test_use_autoload_import_partial_in_opfunc()
mkdir('Xdir/autoload', 'p')
mkdir('Xpartdir/autoload', 'p')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xpartdir'
var lines =<< trim END
vim9script
export def Opfunc(..._)
export def Opfunc1(..._)
g:opfunc_called = 'yes'
enddef
END
writefile(lines, 'Xdir/autoload/opfunc.vim')
writefile(lines, 'Xpartdir/autoload/opfunc.vim')
new
lines =<< trim END
@@ -897,7 +897,7 @@ def Test_use_autoload_import_partial_in_opfunc()
import autoload 'opfunc.vim'
nnoremap <expr> <F3> TheFunc()
def TheFunc(): string
&operatorfunc = function('opfunc.Opfunc', [0])
&operatorfunc = function('opfunc.Opfunc1', [0])
return 'g@'
enddef
feedkeys("\<F3>l", 'xt')
@@ -907,23 +907,23 @@ def Test_use_autoload_import_partial_in_opfunc()
set opfunc=
bwipe!
delete('Xdir', 'rf')
delete('Xpartdir', 'rf')
nunmap <F3>
&rtp = save_rtp
enddef
def Test_set_opfunc_to_autoload_func_directly()
mkdir('Xdir/autoload', 'p')
mkdir('Xdirdir/autoload', 'p')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xdirdir'
var lines =<< trim END
vim9script
export def Opfunc(..._)
export def Opfunc2(..._)
g:opfunc_called = 'yes'
enddef
END
writefile(lines, 'Xdir/autoload/opfunc.vim')
writefile(lines, 'Xdirdir/autoload/opfunc.vim')
new
lines =<< trim END
@@ -931,7 +931,7 @@ def Test_set_opfunc_to_autoload_func_directly()
import autoload 'opfunc.vim'
nnoremap <expr> <F3> TheFunc()
def TheFunc(): string
&operatorfunc = opfunc.Opfunc
&operatorfunc = opfunc.Opfunc2
return 'g@'
enddef
feedkeys("\<F3>l", 'xt')
@@ -941,15 +941,15 @@ def Test_set_opfunc_to_autoload_func_directly()
set opfunc=
bwipe!
delete('Xdir', 'rf')
delete('Xdirdir', 'rf')
nunmap <F3>
&rtp = save_rtp
enddef
def Test_use_autoload_import_in_fold_expression()
mkdir('Xdir/autoload', 'p')
mkdir('Xfolddir/autoload', 'p')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xfolddir'
var lines =<< trim END
vim9script
@@ -961,7 +961,7 @@ def Test_use_autoload_import_in_fold_expression()
enddef
g:fold_loaded = 'yes'
END
writefile(lines, 'Xdir/autoload/fold.vim')
writefile(lines, 'Xfolddir/autoload/fold.vim')
lines =<< trim END
vim9script
@@ -985,7 +985,7 @@ def Test_use_autoload_import_in_fold_expression()
set foldexpr= foldtext& foldmethod& debug=
bwipe!
delete('Xdir', 'rf')
delete('Xfolddir', 'rf')
&rtp = save_rtp
enddef
@@ -1200,7 +1200,7 @@ def Test_autoload_import_deleted()
END
v9.CheckScriptFailure(lines, 'E484:')
delete('Xdir', 'rf')
delete('Xa.vim')
enddef
func Test_import_in_diffexpr()
@@ -1455,9 +1455,9 @@ def Run_Test_import_in_spellsuggest_expr()
enddef
def Test_export_shadows_global_function()
mkdir('Xdir/autoload', 'p')
mkdir('Xglobdir/autoload', 'p')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xglobdir'
var lines =<< trim END
vim9script
@@ -1465,7 +1465,7 @@ def Test_export_shadows_global_function()
return 'Shadow()'
enddef
END
writefile(lines, 'Xdir/autoload/shadow.vim')
writefile(lines, 'Xglobdir/autoload/shadow.vim')
lines =<< trim END
vim9script
@@ -1481,7 +1481,7 @@ def Test_export_shadows_global_function()
delfunc g:Shadow
bwipe!
delete('Xdir', 'rf')
delete('Xglobdir', 'rf')
&rtp = save_rtp
enddef
@@ -2178,10 +2178,10 @@ def Test_vim9_autoload_full_name()
enddef
END
mkdir('Xdir/autoload', 'p')
writefile(lines, 'Xdir/autoload/some.vim')
mkdir('Xfulldir/autoload', 'p')
writefile(lines, 'Xfulldir/autoload/some.vim')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xfulldir'
assert_equal('test', g:some#Gettest())
assert_equal('name', g:some#name)
@@ -2198,17 +2198,17 @@ def Test_vim9_autoload_full_name()
return 'other'
enddef
END
writefile(lines, 'Xdir/autoload/Other.vim')
writefile(lines, 'Xfulldir/autoload/Other.vim')
assert_equal('other', g:Other#GetOther())
delete('Xdir', 'rf')
delete('Xfulldir', 'rf')
&rtp = save_rtp
enddef
def Test_vim9script_autoload()
mkdir('Xdir/autoload', 'p')
mkdir('Xaldir/autoload', 'p')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xaldir'
# when the path has "/autoload/" prefix is not needed
var lines =<< trim END
@@ -2232,7 +2232,7 @@ def Test_vim9script_autoload()
export final fname = 'final'
export const cname = 'const'
END
writefile(lines, 'Xdir/autoload/prefixed.vim')
writefile(lines, 'Xaldir/autoload/prefixed.vim')
g:prefixed_loaded = 0
g:expected_loaded = 0
@@ -2266,14 +2266,14 @@ def Test_vim9script_autoload()
unlet g:prefixed_loaded
unlet g:expected_loaded
delete('Xdir', 'rf')
delete('Xaldir', 'rf')
&rtp = save_rtp
enddef
def Test_import_autoload_not_exported()
mkdir('Xdir/autoload', 'p')
mkdir('Xnimdir/autoload', 'p')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xnimdir'
# error when using an item that is not exported from an autoload script
var exportLines =<< trim END
@@ -2283,7 +2283,7 @@ def Test_import_autoload_not_exported()
echo 'nop'
enddef
END
writefile(exportLines, 'Xdir/autoload/notExport1.vim')
writefile(exportLines, 'Xnimdir/autoload/notExport1.vim')
var lines =<< trim END
vim9script
@@ -2329,7 +2329,7 @@ def Test_import_autoload_not_exported()
# using a :def function we use a different autoload script every time so that
# the function is compiled without the script loaded
writefile(exportLines, 'Xdir/autoload/notExport2.vim')
writefile(exportLines, 'Xnimdir/autoload/notExport2.vim')
lines =<< trim END
vim9script
import autoload 'notExport2.vim'
@@ -2340,7 +2340,7 @@ def Test_import_autoload_not_exported()
END
v9.CheckScriptFailure(lines, 'E1048: Item not found in script: notExport2#notFound')
writefile(exportLines, 'Xdir/autoload/notExport3.vim')
writefile(exportLines, 'Xnimdir/autoload/notExport3.vim')
lines =<< trim END
vim9script
import autoload 'notExport3.vim'
@@ -2352,7 +2352,7 @@ def Test_import_autoload_not_exported()
# don't get E1049 because it is too complicated to figure out
v9.CheckScriptFailure(lines, 'E1048: Item not found in script: notExport3#notExported')
writefile(exportLines, 'Xdir/autoload/notExport4.vim')
writefile(exportLines, 'Xnimdir/autoload/notExport4.vim')
lines =<< trim END
vim9script
import autoload 'notExport4.vim'
@@ -2363,7 +2363,7 @@ def Test_import_autoload_not_exported()
END
v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport4#NotFunc')
writefile(exportLines, 'Xdir/autoload/notExport5.vim')
writefile(exportLines, 'Xnimdir/autoload/notExport5.vim')
lines =<< trim END
vim9script
import autoload 'notExport5.vim'
@@ -2374,7 +2374,7 @@ def Test_import_autoload_not_exported()
END
v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport5#NotExport')
writefile(exportLines, 'Xdir/autoload/notExport6.vim')
writefile(exportLines, 'Xnimdir/autoload/notExport6.vim')
lines =<< trim END
vim9script
import autoload 'notExport6.vim'
@@ -2385,7 +2385,7 @@ def Test_import_autoload_not_exported()
END
v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport6#NotFunc')
writefile(exportLines, 'Xdir/autoload/notExport7.vim')
writefile(exportLines, 'Xnimdir/autoload/notExport7.vim')
lines =<< trim END
vim9script
import autoload 'notExport7.vim'
@@ -2396,14 +2396,14 @@ def Test_import_autoload_not_exported()
END
v9.CheckScriptFailure(lines, 'E117: Unknown function: notExport7#NotExport')
delete('Xdir', 'rf')
delete('Xnimdir', 'rf')
&rtp = save_rtp
enddef
def Test_vim9script_autoload_call()
mkdir('Xdir/autoload', 'p')
mkdir('Xcalldir/autoload', 'p')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xcalldir'
var lines =<< trim END
vim9script
@@ -2416,7 +2416,7 @@ def Test_vim9script_autoload_call()
g:result = 'other'
enddef
END
writefile(lines, 'Xdir/autoload/another.vim')
writefile(lines, 'Xcalldir/autoload/another.vim')
lines =<< trim END
vim9script
@@ -2440,14 +2440,14 @@ def Test_vim9script_autoload_call()
v9.CheckScriptSuccess(lines)
unlet g:result
delete('Xdir', 'rf')
delete('Xcalldir', 'rf')
&rtp = save_rtp
enddef
def Test_vim9script_noclear_autoload()
mkdir('Xdir/autoload', 'p')
mkdir('Xnocdir/autoload', 'p')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xnocdir'
var lines =<< trim END
vim9script
@@ -2456,7 +2456,7 @@ def Test_vim9script_noclear_autoload()
enddef
g:double_loaded = 'yes'
END
writefile(lines, 'Xdir/autoload/double.vim')
writefile(lines, 'Xnocdir/autoload/double.vim')
lines =<< trim END
vim9script noclear
@@ -2482,12 +2482,12 @@ def Test_vim9script_noclear_autoload()
unlet g:double_loaded
unlet g:script_loaded
unlet g:result
delete('Xdir', 'rf')
delete('Xnocdir', 'rf')
&rtp = save_rtp
enddef
def Test_vim9script_autoload_duplicate()
mkdir('Xdir/autoload', 'p')
mkdir('Xdupdir/autoload', 'p')
var lines =<< trim END
vim9script
@@ -2498,8 +2498,8 @@ def Test_vim9script_autoload_duplicate()
def Func()
enddef
END
writefile(lines, 'Xdir/autoload/dupfunc.vim')
assert_fails('source Xdir/autoload/dupfunc.vim', 'E1073:')
writefile(lines, 'Xdupdir/autoload/dupfunc.vim')
assert_fails('source Xdupdir/autoload/dupfunc.vim', 'E1073:')
lines =<< trim END
vim9script
@@ -2510,8 +2510,8 @@ def Test_vim9script_autoload_duplicate()
export def Func()
enddef
END
writefile(lines, 'Xdir/autoload/dup2func.vim')
assert_fails('source Xdir/autoload/dup2func.vim', 'E1073:')
writefile(lines, 'Xdupdir/autoload/dup2func.vim')
assert_fails('source Xdupdir/autoload/dup2func.vim', 'E1073:')
lines =<< trim END
vim9script
@@ -2521,8 +2521,8 @@ def Test_vim9script_autoload_duplicate()
export var Func = 'asdf'
END
writefile(lines, 'Xdir/autoload/dup3func.vim')
assert_fails('source Xdir/autoload/dup3func.vim', 'E1041: Redefining script item: "Func"')
writefile(lines, 'Xdupdir/autoload/dup3func.vim')
assert_fails('source Xdupdir/autoload/dup3func.vim', 'E1041: Redefining script item: "Func"')
lines =<< trim END
vim9script
@@ -2532,8 +2532,8 @@ def Test_vim9script_autoload_duplicate()
def Func()
enddef
END
writefile(lines, 'Xdir/autoload/dup4func.vim')
assert_fails('source Xdir/autoload/dup4func.vim', 'E707:')
writefile(lines, 'Xdupdir/autoload/dup4func.vim')
assert_fails('source Xdupdir/autoload/dup4func.vim', 'E707:')
lines =<< trim END
vim9script
@@ -2543,8 +2543,8 @@ def Test_vim9script_autoload_duplicate()
export def Func()
enddef
END
writefile(lines, 'Xdir/autoload/dup5func.vim')
assert_fails('source Xdir/autoload/dup5func.vim', 'E707:')
writefile(lines, 'Xdupdir/autoload/dup5func.vim')
assert_fails('source Xdupdir/autoload/dup5func.vim', 'E707:')
lines =<< trim END
vim9script
@@ -2554,14 +2554,14 @@ def Test_vim9script_autoload_duplicate()
var Func = 'asdf'
END
writefile(lines, 'Xdir/autoload/dup6func.vim')
assert_fails('source Xdir/autoload/dup6func.vim', 'E1041: Redefining script item: "Func"')
writefile(lines, 'Xdupdir/autoload/dup6func.vim')
assert_fails('source Xdupdir/autoload/dup6func.vim', 'E1041: Redefining script item: "Func"')
delete('Xdir', 'rf')
delete('Xdupdir', 'rf')
enddef
def Test_autoload_missing_function_name()
mkdir('Xdir/autoload', 'p')
mkdir('Xmisdir/autoload', 'p')
var lines =<< trim END
vim9script
@@ -2569,10 +2569,10 @@ def Test_autoload_missing_function_name()
def loadme#()
enddef
END
writefile(lines, 'Xdir/autoload/loadme.vim')
assert_fails('source Xdir/autoload/loadme.vim', 'E129:')
writefile(lines, 'Xmisdir/autoload/loadme.vim')
assert_fails('source Xmisdir/autoload/loadme.vim', 'E129:')
delete('Xdir', 'rf')
delete('Xmisdir', 'rf')
enddef
def Test_autoload_name_wrong()
@@ -2584,22 +2584,22 @@ def Test_autoload_name_wrong()
v9.CheckScriptFailure(lines, 'E746:')
delete('Xscriptname.vim')
mkdir('Xdir/autoload', 'p')
mkdir('Xwrodir/autoload', 'p')
lines =<< trim END
vim9script
def somescript#Func()
enddef
END
writefile(lines, 'Xdir/autoload/somescript.vim')
assert_fails('source Xdir/autoload/somescript.vim', 'E1263:')
writefile(lines, 'Xwrodir/autoload/somescript.vim')
assert_fails('source Xwrodir/autoload/somescript.vim', 'E1263:')
delete('Xdir', 'rf')
delete('Xwrodir', 'rf')
enddef
def Test_import_autoload_postponed()
mkdir('Xdir/autoload', 'p')
mkdir('Xpostdir/autoload', 'p')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xpostdir'
var lines =<< trim END
vim9script
@@ -2610,7 +2610,7 @@ def Test_import_autoload_postponed()
return 'bla'
enddef
END
writefile(lines, 'Xdir/autoload/postponed.vim')
writefile(lines, 'Xpostdir/autoload/postponed.vim')
lines =<< trim END
vim9script
@@ -2628,14 +2628,14 @@ def Test_import_autoload_postponed()
assert_equal('true', g:loaded_postponed)
unlet g:loaded_postponed
delete('Xdir', 'rf')
delete('Xpostdir', 'rf')
&rtp = save_rtp
enddef
def Test_import_autoload_override()
mkdir('Xdir/autoload', 'p')
mkdir('Xoverdir/autoload', 'p')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xoverdir'
test_override('autoload', 1)
var lines =<< trim END
@@ -2647,7 +2647,7 @@ def Test_import_autoload_override()
return 'bla'
enddef
END
writefile(lines, 'Xdir/autoload/override.vim')
writefile(lines, 'Xoverdir/autoload/override.vim')
lines =<< trim END
vim9script
@@ -2664,14 +2664,14 @@ def Test_import_autoload_override()
test_override('autoload', 0)
unlet g:loaded_override
delete('Xdir', 'rf')
delete('Xoverdir', 'rf')
&rtp = save_rtp
enddef
def Test_autoload_mapping()
mkdir('Xdir/autoload', 'p')
mkdir('Xmapdir/autoload', 'p')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xmapdir'
var lines =<< trim END
vim9script
@@ -2685,7 +2685,7 @@ def Test_autoload_mapping()
g:doit_called = 'yes'
enddef
END
writefile(lines, 'Xdir/autoload/toggle.vim')
writefile(lines, 'Xmapdir/autoload/toggle.vim')
lines =<< trim END
vim9script
@@ -2716,7 +2716,7 @@ def Test_autoload_mapping()
nunmap yy
unlet g:toggle_loaded
unlet g:toggle_called
delete('Xdir', 'rf')
delete('Xmapdir', 'rf')
&rtp = save_rtp
enddef
@@ -2774,9 +2774,9 @@ enddef
" test disassembling an auto-loaded function starting with "debug"
def Test_vim9_autoload_disass()
mkdir('Xdir/autoload', 'p')
mkdir('Xdasdir/autoload', 'p')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xdasdir'
var lines =<< trim END
vim9script
@@ -2784,7 +2784,7 @@ def Test_vim9_autoload_disass()
return 'debug'
enddef
END
writefile(lines, 'Xdir/autoload/debugit.vim')
writefile(lines, 'Xdasdir/autoload/debugit.vim')
lines =<< trim END
vim9script
@@ -2792,7 +2792,7 @@ def Test_vim9_autoload_disass()
return 'profile'
enddef
END
writefile(lines, 'Xdir/autoload/profileit.vim')
writefile(lines, 'Xdasdir/autoload/profileit.vim')
lines =<< trim END
vim9script
@@ -2803,7 +2803,7 @@ def Test_vim9_autoload_disass()
END
v9.CheckScriptSuccess(lines)
delete('Xdir', 'rf')
delete('Xdasdir', 'rf')
&rtp = save_rtp
enddef
@@ -2816,10 +2816,10 @@ def Test_vim9_aucmd_autoload()
enddef
END
mkdir('Xdir/autoload', 'p')
writefile(lines, 'Xdir/autoload/foo.vim')
mkdir('Xauldir/autoload', 'p')
writefile(lines, 'Xauldir/autoload/foo.vim')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xauldir'
augroup test
autocmd TextYankPost * call foo#Test()
augroup END
@@ -2829,7 +2829,7 @@ def Test_vim9_aucmd_autoload()
augroup test
autocmd!
augroup END
delete('Xdir', 'rf')
delete('Xauldir', 'rf')
&rtp = save_rtp
enddef
@@ -2842,10 +2842,10 @@ def Test_vim9_autoload_case_sensitive()
enddef
END
mkdir('Xdir/autoload', 'p')
writefile(lines, 'Xdir/autoload/CaseSensitive.vim')
mkdir('Xcasedir/autoload', 'p')
writefile(lines, 'Xcasedir/autoload/CaseSensitive.vim')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xcasedir'
lines =<< trim END
vim9script
@@ -2863,7 +2863,7 @@ def Test_vim9_autoload_case_sensitive()
v9.CheckScriptFailure(lines, 'E1262:')
endif
delete('Xdir', 'rf')
delete('Xcasedir', 'rf')
&rtp = save_rtp
enddef
+4 -4
View File
@@ -3586,13 +3586,13 @@ def Run_test_no_redraw_when_restoring_cpo()
export def Func()
enddef
END
mkdir('Xdir/autoload', 'p')
writefile(lines, 'Xdir/autoload/script.vim')
mkdir('Xnordir/autoload', 'p')
writefile(lines, 'Xnordir/autoload/script.vim')
lines =<< trim END
vim9script
set cpo+=M
exe 'set rtp^=' .. getcwd() .. '/Xdir'
exe 'set rtp^=' .. getcwd() .. '/Xnordir'
au CmdlineEnter : ++once timer_start(0, (_) => script#Func())
setline(1, 'some text')
END
@@ -3605,7 +3605,7 @@ def Run_test_no_redraw_when_restoring_cpo()
term_sendkeys(buf, "\<Esc>u")
g:StopVimInTerminal(buf)
delete('XTest_redraw_cpo')
delete('Xdir', 'rf')
delete('Xnordir', 'rf')
enddef
func Test_reject_declaration()
+4 -4
View File
@@ -962,10 +962,10 @@ func Test_viminfo_perm()
call delete('Xviminfo')
" Try to write the viminfo to a directory
call mkdir('Xdir')
call assert_fails('wviminfo Xdir', 'E137:')
call assert_fails('rviminfo Xdir', 'E195:')
call delete('Xdir', 'rf')
call mkdir('Xvifdir')
call assert_fails('wviminfo Xvifdir', 'E137:')
call assert_fails('rviminfo Xvifdir', 'E195:')
call delete('Xvifdir', 'rf')
endfunc
" Test for writing to an existing viminfo file merges the file marks
+11 -11
View File
@@ -251,9 +251,9 @@ func Test_write_errors()
" Try to overwrite a directory
if has('unix')
call mkdir('Xdir1')
call assert_fails('write Xdir1', 'E17:')
call delete('Xdir1', 'd')
call mkdir('Xwerdir1')
call assert_fails('write Xwerdir1', 'E17:')
call delete('Xwerdir1', 'd')
endif
" Test for :wall for a buffer with no name
@@ -479,20 +479,20 @@ func Test_write_readonly_dir()
" Root can do it too.
CheckNotRoot
call mkdir('Xdir/')
call writefile(['one'], 'Xdir/Xfile1')
call setfperm('Xdir', 'r-xr--r--')
call mkdir('Xrodir/')
call writefile(['one'], 'Xrodir/Xfile1')
call setfperm('Xrodir', 'r-xr--r--')
" try to create a new file in the directory
new Xdir/Xfile2
new Xrodir/Xfile2
call setline(1, 'two')
call assert_fails('write', 'E212:')
" try to create a backup file in the directory
edit! Xdir/Xfile1
set backupdir=./Xdir backupskip=
edit! Xrodir/Xfile1
set backupdir=./Xrodir backupskip=
set patchmode=.orig
call assert_fails('write', 'E509:')
call setfperm('Xdir', 'rwxr--r--')
call delete('Xdir', 'rf')
call setfperm('Xrodir', 'rwxr--r--')
call delete('Xrodir', 'rf')
set backupdir& backupskip& patchmode&
endfunc
+26
View File
@@ -722,6 +722,32 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
325,
/**/
324,
/**/
323,
/**/
322,
/**/
321,
/**/
320,
/**/
319,
/**/
318,
/**/
317,
/**/
316,
/**/
315,
/**/
314,
/**/
313,
/**/
312,
/**/
+1 -1
View File
@@ -3095,7 +3095,7 @@ write_viminfo(char_u *file, int forceit)
{
int tt = msg_didany;
// avoid a wait_return for this message, it's annoying
// avoid a wait_return() for this message, it's annoying
semsg(_(e_viminfo_file_is_not_writable_str), fname);
msg_didany = tt;
fclose(fp_in);