Merge #11873 from janlazo/vim-8.1.0786

vim-patch:8.0.1660,8.1.{43,786,1201,2129,2131,2187,2223,2259},8.2.{241,267}
This commit is contained in:
Justin M. Keyes
2020-02-16 23:18:24 -08:00
committed by GitHub
22 changed files with 222 additions and 99 deletions

View File

@@ -1773,7 +1773,7 @@ def CheckSpacingForFunctionCall(filename, line, linenum, error):
fncall = match.group(1) fncall = match.group(1)
break break
# Except in if/for/while/switch, there should never be space # Except in if/for/while/switch/case, there should never be space
# immediately inside parens (eg "f( 3, 4 )"). We make an exception # immediately inside parens (eg "f( 3, 4 )"). We make an exception
# for nested parens ( (a+b) + c ). Likewise, there should never be # for nested parens ( (a+b) + c ). Likewise, there should never be
# a space before a ( when it's a function argument. I assume it's a # a space before a ( when it's a function argument. I assume it's a
@@ -1787,7 +1787,7 @@ def CheckSpacingForFunctionCall(filename, line, linenum, error):
# Note that we assume the contents of [] to be short enough that # Note that we assume the contents of [] to be short enough that
# they'll never need to wrap. # they'll never need to wrap.
if ( # Ignore control structures. if ( # Ignore control structures.
not Search(r'\b(if|for|while|switch|return|sizeof)\b', fncall) and not Search(r'\b(if|for|while|switch|case|return|sizeof)\b', fncall) and
# Ignore pointers/references to functions. # Ignore pointers/references to functions.
not Search(r' \([^)]+\)\([^)]*(\)|,$)', fncall) and not Search(r' \([^)]+\)\([^)]*(\)|,$)', fncall) and
# Ignore pointers/references to arrays. # Ignore pointers/references to arrays.

View File

@@ -3397,14 +3397,27 @@ int build_stl_str_hl(
fillchar = '-'; fillchar = '-';
} }
// The cursor in windows other than the current one isn't always
// up-to-date, esp. because of autocommands and timers.
linenr_T lnum = wp->w_cursor.lnum;
if (lnum > wp->w_buffer->b_ml.ml_line_count) {
lnum = wp->w_buffer->b_ml.ml_line_count;
wp->w_cursor.lnum = lnum;
}
// Get line & check if empty (cursorpos will show "0-1"). // Get line & check if empty (cursorpos will show "0-1").
char_u *line_ptr = ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, false); const char_u *line_ptr = ml_get_buf(wp->w_buffer, lnum, false);
bool empty_line = (*line_ptr == NUL); bool empty_line = (*line_ptr == NUL);
// Get the byte value now, in case we need it below. This is more // Get the byte value now, in case we need it below. This is more
// efficient than making a copy of the line. // efficient than making a copy of the line.
int byteval; int byteval;
if (wp->w_cursor.col > (colnr_T)STRLEN(line_ptr)) { const size_t len = STRLEN(line_ptr);
if (wp->w_cursor.col > (colnr_T)len) {
// Line may have changed since checking the cursor column, or the lnum
// was adjusted above.
wp->w_cursor.col = (colnr_T)len;
wp->w_cursor.coladd = 0;
byteval = 0; byteval = 0;
} else { } else {
byteval = utf_ptr2char(line_ptr + wp->w_cursor.col); byteval = utf_ptr2char(line_ptr + wp->w_cursor.col);

View File

@@ -2852,7 +2852,8 @@ void ex_call(exarg_T *eap)
} }
} }
if (!failed) { // When inside :try we need to check for following "| catch".
if (!failed || eap->cstack->cs_trylevel > 0) {
// Check for trailing illegal characters and a following command. // Check for trailing illegal characters and a following command.
if (!ends_excmd(*arg)) { if (!ends_excmd(*arg)) {
emsg_severe = TRUE; emsg_severe = TRUE;
@@ -9151,10 +9152,7 @@ char_u *v_throwpoint(char_u *oldval)
*/ */
char_u *set_cmdarg(exarg_T *eap, char_u *oldarg) char_u *set_cmdarg(exarg_T *eap, char_u *oldarg)
{ {
char_u *oldval; char_u *oldval = vimvars[VV_CMDARG].vv_str;
char_u *newval;
oldval = vimvars[VV_CMDARG].vv_str;
if (eap == NULL) { if (eap == NULL) {
xfree(oldval); xfree(oldval);
vimvars[VV_CMDARG].vv_str = oldarg; vimvars[VV_CMDARG].vv_str = oldarg;
@@ -9170,14 +9168,18 @@ char_u *set_cmdarg(exarg_T *eap, char_u *oldarg)
if (eap->read_edit) if (eap->read_edit)
len += 7; len += 7;
if (eap->force_ff != 0) if (eap->force_ff != 0) {
len += STRLEN(eap->cmd + eap->force_ff) + 6; len += 10; // " ++ff=unix"
if (eap->force_enc != 0) }
if (eap->force_enc != 0) {
len += STRLEN(eap->cmd + eap->force_enc) + 7; len += STRLEN(eap->cmd + eap->force_enc) + 7;
if (eap->bad_char != 0) }
len += 7 + 4; /* " ++bad=" + "keep" or "drop" */ if (eap->bad_char != 0) {
len += 7 + 4; // " ++bad=" + "keep" or "drop"
}
newval = xmalloc(len + 1); const size_t newval_len = len + 1;
char_u *newval = xmalloc(newval_len);
if (eap->force_bin == FORCE_BIN) if (eap->force_bin == FORCE_BIN)
sprintf((char *)newval, " ++bin"); sprintf((char *)newval, " ++bin");
@@ -9189,18 +9191,23 @@ char_u *set_cmdarg(exarg_T *eap, char_u *oldarg)
if (eap->read_edit) if (eap->read_edit)
STRCAT(newval, " ++edit"); STRCAT(newval, " ++edit");
if (eap->force_ff != 0) if (eap->force_ff != 0) {
sprintf((char *)newval + STRLEN(newval), " ++ff=%s", snprintf((char *)newval + STRLEN(newval), newval_len, " ++ff=%s",
eap->cmd + eap->force_ff); eap->force_ff == 'u' ? "unix" :
if (eap->force_enc != 0) eap->force_ff == 'd' ? "dos" : "mac");
sprintf((char *)newval + STRLEN(newval), " ++enc=%s", }
eap->cmd + eap->force_enc); if (eap->force_enc != 0) {
if (eap->bad_char == BAD_KEEP) snprintf((char *)newval + STRLEN(newval), newval_len, " ++enc=%s",
eap->cmd + eap->force_enc);
}
if (eap->bad_char == BAD_KEEP) {
STRCPY(newval + STRLEN(newval), " ++bad=keep"); STRCPY(newval + STRLEN(newval), " ++bad=keep");
else if (eap->bad_char == BAD_DROP) } else if (eap->bad_char == BAD_DROP) {
STRCPY(newval + STRLEN(newval), " ++bad=drop"); STRCPY(newval + STRLEN(newval), " ++bad=drop");
else if (eap->bad_char != 0) } else if (eap->bad_char != 0) {
sprintf((char *)newval + STRLEN(newval), " ++bad=%c", eap->bad_char); snprintf((char *)newval + STRLEN(newval), newval_len, " ++bad=%c",
eap->bad_char);
}
vimvars[VV_CMDARG].vv_str = newval; vimvars[VV_CMDARG].vv_str = newval;
return oldval; return oldval;
} }

View File

@@ -160,7 +160,7 @@ struct exarg {
int regname; ///< register name (NUL if none) int regname; ///< register name (NUL if none)
int force_bin; ///< 0, FORCE_BIN or FORCE_NOBIN int force_bin; ///< 0, FORCE_BIN or FORCE_NOBIN
int read_edit; ///< ++edit argument int read_edit; ///< ++edit argument
int force_ff; ///< ++ff= argument (index in cmd[]) int force_ff; ///< ++ff= argument (first char of argument)
int force_enc; ///< ++enc= argument (index in cmd[]) int force_enc; ///< ++enc= argument (index in cmd[])
int bad_char; ///< BAD_KEEP, BAD_DROP or replacement byte int bad_char; ///< BAD_KEEP, BAD_DROP or replacement byte
int useridx; ///< user command index int useridx; ///< user command index

View File

@@ -4373,7 +4373,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp)
if (has_wildcards) { if (has_wildcards) {
expand_T xpc; expand_T xpc;
int options = WILD_LIST_NOTFOUND|WILD_ADD_SLASH; int options = WILD_LIST_NOTFOUND | WILD_NOERROR | WILD_ADD_SLASH;
ExpandInit(&xpc); ExpandInit(&xpc);
xpc.xp_context = EXPAND_FILES; xpc.xp_context = EXPAND_FILES;
@@ -4538,6 +4538,21 @@ skip_cmd_arg (
return p; return p;
} }
int get_bad_opt(const char_u *p, exarg_T *eap)
FUNC_ATTR_NONNULL_ALL
{
if (STRICMP(p, "keep") == 0) {
eap->bad_char = BAD_KEEP;
} else if (STRICMP(p, "drop") == 0) {
eap->bad_char = BAD_DROP;
} else if (MB_BYTE2LEN(*p) == 1 && p[1] == NUL) {
eap->bad_char = *p;
} else {
return FAIL;
}
return OK;
}
/* /*
* Get "++opt=arg" argument. * Get "++opt=arg" argument.
* Return FAIL or OK. * Return FAIL or OK.
@@ -4596,8 +4611,10 @@ static int getargopt(exarg_T *eap)
*arg = NUL; *arg = NUL;
if (pp == &eap->force_ff) { if (pp == &eap->force_ff) {
if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) {
return FAIL; return FAIL;
}
eap->force_ff = eap->cmd[eap->force_ff];
} else if (pp == &eap->force_enc) { } else if (pp == &eap->force_enc) {
/* Make 'fileencoding' lower case. */ /* Make 'fileencoding' lower case. */
for (p = eap->cmd + eap->force_enc; *p != NUL; ++p) for (p = eap->cmd + eap->force_enc; *p != NUL; ++p)
@@ -4605,15 +4622,9 @@ static int getargopt(exarg_T *eap)
} else { } else {
/* Check ++bad= argument. Must be a single-byte character, "keep" or /* Check ++bad= argument. Must be a single-byte character, "keep" or
* "drop". */ * "drop". */
p = eap->cmd + bad_char_idx; if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL) {
if (STRICMP(p, "keep") == 0)
eap->bad_char = BAD_KEEP;
else if (STRICMP(p, "drop") == 0)
eap->bad_char = BAD_DROP;
else if (MB_BYTE2LEN(*p) == 1 && p[1] == NUL)
eap->bad_char = *p;
else
return FAIL; return FAIL;
}
} }
return OK; return OK;
@@ -5130,9 +5141,8 @@ static char *get_command_complete(int arg)
static void uc_list(char_u *name, size_t name_len) static void uc_list(char_u *name, size_t name_len)
{ {
int i, j; int i, j;
int found = FALSE; bool found = false;
ucmd_T *cmd; ucmd_T *cmd;
int len;
uint32_t a; uint32_t a;
// In cmdwin, the alternative buffer should be used. // In cmdwin, the alternative buffer should be used.
@@ -5151,62 +5161,96 @@ static void uc_list(char_u *name, size_t name_len)
continue; continue;
} }
/* Put out the title first time */ // Put out the title first time
if (!found) if (!found) {
MSG_PUTS_TITLE(_("\n Name Args Address Complete Definition")); MSG_PUTS_TITLE(_("\n Name Args Address "
found = TRUE; "Complete Definition"));
}
found = true;
msg_putchar('\n'); msg_putchar('\n');
if (got_int) if (got_int)
break; break;
/* Special cases */ // Special cases
msg_putchar(a & BANG ? '!' : ' '); int len = 4;
msg_putchar(a & REGSTR ? '"' : ' '); if (a & BANG) {
msg_putchar(gap != &ucmds ? 'b' : ' '); msg_putchar('!');
msg_putchar(' '); len--;
}
if (a & REGSTR) {
msg_putchar('"');
len--;
}
if (gap != &ucmds) {
msg_putchar('b');
len--;
}
if (a & TRLBAR) {
msg_putchar('|');
len--;
}
while (len-- > 0) {
msg_putchar(' ');
}
msg_outtrans_attr(cmd->uc_name, HL_ATTR(HLF_D)); msg_outtrans_attr(cmd->uc_name, HL_ATTR(HLF_D));
len = (int)STRLEN(cmd->uc_name) + 4; len = (int)STRLEN(cmd->uc_name) + 4;
do { do {
msg_putchar(' '); msg_putchar(' ');
++len; len++;
} while (len < 16); } while (len < 22);
// "over" is how much longer the name is than the column width for
// the name, we'll try to align what comes after.
const int over = len - 22;
len = 0; len = 0;
/* Arguments */ // Arguments
switch (a & (EXTRA|NOSPC|NEEDARG)) { switch (a & (EXTRA|NOSPC|NEEDARG)) {
case 0: IObuff[len++] = '0'; break; case 0:
case (EXTRA): IObuff[len++] = '*'; break; IObuff[len++] = '0';
case (EXTRA|NOSPC): IObuff[len++] = '?'; break; break;
case (EXTRA|NEEDARG): IObuff[len++] = '+'; break; case (EXTRA):
case (EXTRA|NOSPC|NEEDARG): IObuff[len++] = '1'; break; IObuff[len++] = '*';
break;
case (EXTRA|NOSPC):
IObuff[len++] = '?';
break;
case (EXTRA|NEEDARG):
IObuff[len++] = '+';
break;
case (EXTRA|NOSPC|NEEDARG):
IObuff[len++] = '1';
break;
} }
do { do {
IObuff[len++] = ' '; IObuff[len++] = ' ';
} while (len < 5); } while (len < 5 - over);
/* Range */ // Address / Range
if (a & (RANGE|COUNT)) { if (a & (RANGE|COUNT)) {
if (a & COUNT) { if (a & COUNT) {
/* -count=N */ // -count=N
sprintf((char *)IObuff + len, "%" PRId64 "c", (int64_t)cmd->uc_def); snprintf((char *)IObuff + len, IOSIZE, "%" PRId64 "c",
(int64_t)cmd->uc_def);
len += (int)STRLEN(IObuff + len); len += (int)STRLEN(IObuff + len);
} else if (a & DFLALL) } else if (a & DFLALL) {
IObuff[len++] = '%'; IObuff[len++] = '%';
else if (cmd->uc_def >= 0) { } else if (cmd->uc_def >= 0) {
/* -range=N */ // -range=N
sprintf((char *)IObuff + len, "%" PRId64 "", (int64_t)cmd->uc_def); snprintf((char *)IObuff + len, IOSIZE, "%" PRId64 "",
(int64_t)cmd->uc_def);
len += (int)STRLEN(IObuff + len); len += (int)STRLEN(IObuff + len);
} else } else {
IObuff[len++] = '.'; IObuff[len++] = '.';
}
} }
do { do {
IObuff[len++] = ' '; IObuff[len++] = ' ';
} while (len < 11); } while (len < 9 - over);
// Address Type // Address Type
for (j = 0; addr_type_complete[j].expand != -1; j++) { for (j = 0; addr_type_complete[j].expand != -1; j++) {
@@ -5220,7 +5264,7 @@ static void uc_list(char_u *name, size_t name_len)
do { do {
IObuff[len++] = ' '; IObuff[len++] = ' ';
} while (len < 21); } while (len < 13 - over);
// Completion // Completion
char *cmd_compl = get_command_complete(cmd->uc_compl); char *cmd_compl = get_command_complete(cmd->uc_compl);
@@ -5231,12 +5275,13 @@ static void uc_list(char_u *name, size_t name_len)
do { do {
IObuff[len++] = ' '; IObuff[len++] = ' ';
} while (len < 35); } while (len < 24 - over);
IObuff[len] = '\0'; IObuff[len] = '\0';
msg_outtrans(IObuff); msg_outtrans(IObuff);
msg_outtrans_special(cmd->uc_rep, false); msg_outtrans_special(cmd->uc_rep, false,
name_len == 0 ? Columns - 46 : 0);
if (p_verbose > 0) { if (p_verbose > 0) {
last_set_msg(cmd->uc_script_ctx); last_set_msg(cmd->uc_script_ctx);
} }
@@ -5424,9 +5469,8 @@ static void ex_command(exarg_T *eap)
end = p; end = p;
name_len = (int)(end - name); name_len = (int)(end - name);
/* If there is nothing after the name, and no attributes were specified, // If there is nothing after the name, and no attributes were specified,
* we are listing commands // we are listing commands
*/
p = skipwhite(end); p = skipwhite(end);
if (!has_attr && ends_excmd(*p)) { if (!has_attr && ends_excmd(*p)) {
uc_list(name, end - name); uc_list(name, end - name);

View File

@@ -4693,6 +4693,9 @@ ExpandFromContext (
flags |= EW_KEEPALL; flags |= EW_KEEPALL;
if (options & WILD_SILENT) if (options & WILD_SILENT)
flags |= EW_SILENT; flags |= EW_SILENT;
if (options & WILD_NOERROR) {
flags |= EW_NOERROR;
}
if (options & WILD_ALLLINKS) { if (options & WILD_ALLLINKS) {
flags |= EW_ALLLINKS; flags |= EW_ALLLINKS;
} }

View File

@@ -2032,14 +2032,16 @@ readfile_linenr(
* Fill "*eap" to force the 'fileencoding', 'fileformat' and 'binary to be * Fill "*eap" to force the 'fileencoding', 'fileformat' and 'binary to be
* equal to the buffer "buf". Used for calling readfile(). * equal to the buffer "buf". Used for calling readfile().
*/ */
void prep_exarg(exarg_T *eap, buf_T *buf) void prep_exarg(exarg_T *eap, const buf_T *buf)
FUNC_ATTR_NONNULL_ALL
{ {
eap->cmd = xmalloc(STRLEN(buf->b_p_ff) + STRLEN(buf->b_p_fenc) + 15); const size_t cmd_len = 15 + STRLEN(buf->b_p_fenc);
eap->cmd = xmalloc(cmd_len);
sprintf((char *)eap->cmd, "e ++ff=%s ++enc=%s", buf->b_p_ff, buf->b_p_fenc); snprintf((char *)eap->cmd, cmd_len, "e ++enc=%s", buf->b_p_fenc);
eap->force_enc = 14 + (int)STRLEN(buf->b_p_ff); eap->force_enc = 8;
eap->bad_char = buf->b_bad_char; eap->bad_char = buf->b_bad_char;
eap->force_ff = 7; eap->force_ff = *buf->b_p_ff;
eap->force_bin = buf->b_p_bin ? FORCE_BIN : FORCE_NOBIN; eap->force_bin = buf->b_p_bin ? FORCE_BIN : FORCE_NOBIN;
eap->read_edit = FALSE; eap->read_edit = FALSE;

View File

@@ -3361,7 +3361,7 @@ showmap (
msg_putchar(' '); msg_putchar(' ');
// Display the LHS. Get length of what we write. // Display the LHS. Get length of what we write.
len = (size_t)msg_outtrans_special(mp->m_keys, true); len = (size_t)msg_outtrans_special(mp->m_keys, true, 0);
do { do {
msg_putchar(' '); /* padd with blanks */ msg_putchar(' '); /* padd with blanks */
++len; ++len;
@@ -3389,7 +3389,7 @@ showmap (
// as typeahead. // as typeahead.
char_u *s = vim_strsave(mp->m_str); char_u *s = vim_strsave(mp->m_str);
vim_unescape_csi(s); vim_unescape_csi(s);
msg_outtrans_special(s, FALSE); msg_outtrans_special(s, false, 0);
xfree(s); xfree(s);
} }
if (p_verbose > 0) { if (p_verbose > 0) {

View File

@@ -1863,7 +1863,10 @@ errorret:
// Avoid giving this message for a recursive call, may happen // Avoid giving this message for a recursive call, may happen
// when the GUI redraws part of the text. // when the GUI redraws part of the text.
recursive++; recursive++;
IEMSGN(_("E316: ml_get: cannot find line %" PRId64), lnum); get_trans_bufname(buf);
shorten_dir(NameBuff);
iemsgf(_("E316: ml_get: cannot find line %" PRId64 " in buffer %d %s"),
lnum, buf->b_fnum, NameBuff);
recursive--; recursive--;
} }
goto errorret; goto errorret;

View File

@@ -868,7 +868,7 @@ static void show_menus_recursive(vimmenu_T *menu, int modes, int depth)
if (*menu->strings[bit] == NUL) { if (*menu->strings[bit] == NUL) {
msg_puts_attr("<Nop>", HL_ATTR(HLF_8)); msg_puts_attr("<Nop>", HL_ATTR(HLF_8));
} else { } else {
msg_outtrans_special(menu->strings[bit], false); msg_outtrans_special(menu->strings[bit], false, 0);
} }
} }
} else { } else {

View File

@@ -1521,7 +1521,8 @@ void msg_make(char_u *arg)
/// the character/string -- webb /// the character/string -- webb
int msg_outtrans_special( int msg_outtrans_special(
const char_u *strstart, const char_u *strstart,
int from ///< true for LHS of a mapping bool from, ///< true for LHS of a mapping
int maxlen ///< screen columns, 0 for unlimeted
) )
{ {
if (strstart == NULL) { if (strstart == NULL) {
@@ -1541,6 +1542,9 @@ int msg_outtrans_special(
string = str2special((const char **)&str, from, false); string = str2special((const char **)&str, from, false);
} }
const int len = vim_strsize((char_u *)string); const int len = vim_strsize((char_u *)string);
if (maxlen > 0 && retval + len >= maxlen) {
break;
}
// Highlight special keys // Highlight special keys
msg_puts_attr(string, (len > 1 msg_puts_attr(string, (len > 1
&& (*mb_ptr2len)((char_u *)string) <= 1 && (*mb_ptr2len)((char_u *)string) <= 1

View File

@@ -7294,12 +7294,13 @@ int get_fileformat(buf_T *buf)
/// argument. /// argument.
/// ///
/// @param eap can be NULL! /// @param eap can be NULL!
int get_fileformat_force(buf_T *buf, exarg_T *eap) int get_fileformat_force(const buf_T *buf, const exarg_T *eap)
FUNC_ATTR_NONNULL_ARG(1)
{ {
int c; int c;
if (eap != NULL && eap->force_ff != 0) { if (eap != NULL && eap->force_ff != 0) {
c = eap->cmd[eap->force_ff]; c = eap->force_ff;
} else { } else {
if ((eap != NULL && eap->force_bin != 0) if ((eap != NULL && eap->force_bin != 0)
? (eap->force_bin == FORCE_BIN) : buf->b_p_bin) { ? (eap->force_bin == FORCE_BIN) : buf->b_p_bin) {

View File

@@ -3845,7 +3845,7 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last)
*dirname = NUL; *dirname = NUL;
// Add one line for each error // Add one line for each error
if (old_last == NULL) { if (old_last == NULL || old_last->qf_next == NULL) {
qfp = qfl->qf_start; qfp = qfl->qf_start;
lnum = 0; lnum = 0;
} else { } else {

View File

@@ -86,7 +86,7 @@ nongui: nolog $(FIXFF) $(SCRIPTS) newtests report
@echo 'set $$_exitcode = -1\nrun\nif $$_exitcode != -1\n quit\nend' > .gdbinit @echo 'set $$_exitcode = -1\nrun\nif $$_exitcode != -1\n quit\nend' > .gdbinit
report: report:
$(RUN_VIMTEST) $(NO_INITS) -u NONE -S summarize.vim messages $(NVIM_PRG) -u NONE $(NO_INITS) -S summarize.vim messages
@echo @echo
@echo 'Test results:' @echo 'Test results:'
@cat test_result.log @cat test_result.log

View File

@@ -1,6 +1,6 @@
" Vim script language tests " Vim script language tests
" Author: Servatius Brandt <Servatius.Brandt@fujitsu-siemens.com> " Author: Servatius Brandt <Servatius.Brandt@fujitsu-siemens.com>
" Last Change: 2019 May 24 " Last Change: 2019 Oct 08
"------------------------------------------------------------------------------- "-------------------------------------------------------------------------------
" Test environment {{{1 " Test environment {{{1
@@ -456,7 +456,7 @@ function! ExtraVim(...)
" messing up the user's viminfo file. " messing up the user's viminfo file.
let redirect = a:0 ? let redirect = a:0 ?
\ " -c 'au VimLeave * redir END' -c 'redir\\! >" . a:1 . "'" : "" \ " -c 'au VimLeave * redir END' -c 'redir\\! >" . a:1 . "'" : ""
exec "!echo '" . debug_quits . "q' | $NVIM_PRG -u NONE -N -es" . redirect . exec "!echo '" . debug_quits . "q' | " .. v:progpath .. " -u NONE -N -es" . redirect .
\ " -c 'debuggreedy|set viminfo+=nviminfo'" . \ " -c 'debuggreedy|set viminfo+=nviminfo'" .
\ " -c 'let ExtraVimBegin = " . extra_begin . "'" . \ " -c 'let ExtraVimBegin = " . extra_begin . "'" .
\ " -c 'let ExtraVimResult = \"" . resultfile . "\"'" . breakpoints . \ " -c 'let ExtraVimResult = \"" . resultfile . "\"'" . breakpoints .

View File

@@ -38,10 +38,11 @@ func Test_compiler()
endfunc endfunc
func Test_compiler_without_arg() func Test_compiler_without_arg()
let a=split(execute('compiler')) let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')
call assert_match('^.*runtime/compiler/ant.vim$', a[0]) let a = split(execute('compiler'))
call assert_match('^.*runtime/compiler/bcc.vim$', a[1]) call assert_match(runtime .. '/compiler/ant.vim$', a[0])
call assert_match('^.*runtime/compiler/xmlwf.vim$', a[-1]) call assert_match(runtime .. '/compiler/bcc.vim$', a[1])
call assert_match(runtime .. '/compiler/xmlwf.vim$', a[-1])
endfunc endfunc
func Test_compiler_completion() func Test_compiler_completion()

View File

@@ -8,3 +8,31 @@ function Test_edit()
call delete('Xfile1') call delete('Xfile1')
call delete('Xfile2') call delete('Xfile2')
endfunction endfunction
func Test_edit_bad()
if !has('multi_byte')
finish
endif
" Test loading a utf8 file with bad utf8 sequences.
call writefile(["[\xff][\xc0][\xe2\x89\xf0][\xc2\xc2]"], "Xfile")
new
" Without ++bad=..., the default behavior is like ++bad=?
e! ++enc=utf8 Xfile
call assert_equal('[?][?][???][??]', getline(1))
e! ++enc=utf8 ++bad=_ Xfile
call assert_equal('[_][_][___][__]', getline(1))
e! ++enc=utf8 ++bad=drop Xfile
call assert_equal('[][][][]', getline(1))
e! ++enc=utf8 ++bad=keep Xfile
call assert_equal("[\xff][\xc0][\xe2\x89\xf0][\xc2\xc2]", getline(1))
call assert_fails('e! ++enc=utf8 ++bad=foo Xfile', 'E474:')
bw!
call delete('Xfile')
endfunc

View File

@@ -1510,6 +1510,13 @@ func Test_setqflist_invalid_nr()
call setqflist([], ' ', {'nr' : $XXX_DOES_NOT_EXIST}) call setqflist([], ' ', {'nr' : $XXX_DOES_NOT_EXIST})
endfunc endfunc
func Test_setqflist_user_sets_buftype()
call setqflist([{'text': 'foo'}, {'text': 'bar'}])
set buftype=quickfix
call setqflist([], 'a')
enew
endfunc
func Test_quickfix_set_list_with_act() func Test_quickfix_set_list_with_act()
call XquickfixSetListWithAct('c') call XquickfixSetListWithAct('c')
call XquickfixSetListWithAct('l') call XquickfixSetListWithAct('l')

View File

@@ -130,20 +130,21 @@ endfunc
func Test_spellinfo() func Test_spellinfo()
throw 'skipped: Nvim does not support enc=latin1' throw 'skipped: Nvim does not support enc=latin1'
new new
let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')
set enc=latin1 spell spelllang=en set enc=latin1 spell spelllang=en
call assert_match("^\nfile: .*/runtime/spell/en.latin1.spl\n$", execute('spellinfo')) call assert_match("^\nfile: " .. runtime .. "/spell/en.latin1.spl\n$", execute('spellinfo'))
set enc=cp1250 spell spelllang=en set enc=cp1250 spell spelllang=en
call assert_match("^\nfile: .*/runtime/spell/en.ascii.spl\n$", execute('spellinfo')) call assert_match("^\nfile: " .. runtime .. "/spell/en.ascii.spl\n$", execute('spellinfo'))
set enc=utf-8 spell spelllang=en set enc=utf-8 spell spelllang=en
call assert_match("^\nfile: .*/runtime/spell/en.utf-8.spl\n$", execute('spellinfo')) call assert_match("^\nfile: " .. runtime .. "/spell/en.utf-8.spl\n$", execute('spellinfo'))
set enc=latin1 spell spelllang=en_us,en_nz set enc=latin1 spell spelllang=en_us,en_nz
call assert_match("^\n" . call assert_match("^\n" .
\ "file: .*/runtime/spell/en.latin1.spl\n" . \ "file: " .. runtime .. "/spell/en.latin1.spl\n" .
\ "file: .*/runtime/spell/en.latin1.spl\n$", execute('spellinfo')) \ "file: " .. runtime .. "/spell/en.latin1.spl\n$", execute('spellinfo'))
set spell spelllang= set spell spelllang=
call assert_fails('spellinfo', 'E756:') call assert_fails('spellinfo', 'E756:')

View File

@@ -94,3 +94,7 @@ func Test_user_func()
unlet g:retval g:counter unlet g:retval g:counter
enew! enew!
endfunc endfunc
func Test_failed_call_in_try()
try | call UnknownFunc() | catch | endtry
endfunc

View File

@@ -1,4 +1,4 @@
" Tests for the writefile() function. " Tests for the writefile() function and some :write commands.
func Test_writefile() func Test_writefile()
let f = tempname() let f = tempname()
@@ -16,6 +16,11 @@ func Test_writefile()
call delete(f) call delete(f)
endfunc endfunc
func Test_writefile_ignore_regexp_error()
write Xt[z-a]est.txt
call delete('Xt[z-a]est.txt')
endfunc
func Test_writefile_fails_gently() func Test_writefile_fails_gently()
call assert_fails('call writefile(["test"], "Xfile", [])', 'E730:') call assert_fails('call writefile(["test"], "Xfile", [])', 'E730:')
call assert_false(filereadable("Xfile")) call assert_false(filereadable("Xfile"))

View File

@@ -187,7 +187,7 @@ void terminfo_info_msg(const unibi_term *const ut)
msg_printf_attr(0, " %-25s %-10s = ", unibi_name_str(i), msg_printf_attr(0, " %-25s %-10s = ", unibi_name_str(i),
unibi_short_name_str(i)); unibi_short_name_str(i));
// Most of these strings will contain escape sequences. // Most of these strings will contain escape sequences.
msg_outtrans_special((char_u *)s, false); msg_outtrans_special((char_u *)s, false, 0);
msg_putchar('\n'); msg_putchar('\n');
} }
} }
@@ -214,7 +214,7 @@ void terminfo_info_msg(const unibi_term *const ut)
msg_puts("Extended string capabilities:\n"); msg_puts("Extended string capabilities:\n");
for (size_t i = 0; i < unibi_count_ext_str(ut); i++) { for (size_t i = 0; i < unibi_count_ext_str(ut); i++) {
msg_printf_attr(0, " %-25s = ", unibi_get_ext_str_name(ut, i)); msg_printf_attr(0, " %-25s = ", unibi_get_ext_str_name(ut, i));
msg_outtrans_special((char_u *)unibi_get_ext_str(ut, i), false); msg_outtrans_special((char_u *)unibi_get_ext_str(ut, i), false, 0);
msg_putchar('\n'); msg_putchar('\n');
} }
} }