diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/clint.py | 4 | ||||
-rw-r--r-- | src/nvim/buffer.c | 17 | ||||
-rw-r--r-- | src/nvim/eval.c | 49 | ||||
-rw-r--r-- | src/nvim/ex_cmds_defs.h | 2 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 134 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 3 | ||||
-rw-r--r-- | src/nvim/fileio.c | 12 | ||||
-rw-r--r-- | src/nvim/getchar.c | 4 | ||||
-rw-r--r-- | src/nvim/memline.c | 5 | ||||
-rw-r--r-- | src/nvim/menu.c | 2 | ||||
-rw-r--r-- | src/nvim/message.c | 6 | ||||
-rw-r--r-- | src/nvim/option.c | 5 | ||||
-rw-r--r-- | src/nvim/quickfix.c | 2 | ||||
-rw-r--r-- | src/nvim/testdir/Makefile | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test49.vim | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_compiler.vim | 9 | ||||
-rw-r--r-- | src/nvim/testdir/test_plus_arg_edit.vim | 28 | ||||
-rw-r--r-- | src/nvim/testdir/test_quickfix.vim | 7 | ||||
-rw-r--r-- | src/nvim/testdir/test_spell.vim | 11 | ||||
-rw-r--r-- | src/nvim/testdir/test_user_func.vim | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_writefile.vim | 7 | ||||
-rw-r--r-- | src/nvim/tui/terminfo.c | 4 |
22 files changed, 222 insertions, 99 deletions
diff --git a/src/clint.py b/src/clint.py index 12bada6aac..8dc41fdb93 100755 --- a/src/clint.py +++ b/src/clint.py @@ -1773,7 +1773,7 @@ def CheckSpacingForFunctionCall(filename, line, linenum, error): fncall = match.group(1) 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 # 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 @@ -1787,7 +1787,7 @@ def CheckSpacingForFunctionCall(filename, line, linenum, error): # Note that we assume the contents of [] to be short enough that # they'll never need to wrap. 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. not Search(r' \([^)]+\)\([^)]*(\)|,$)', fncall) and # Ignore pointers/references to arrays. diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 790609ab94..c2573cf942 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -3397,14 +3397,27 @@ int build_stl_str_hl( 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"). - 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); // Get the byte value now, in case we need it below. This is more // efficient than making a copy of the line. 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; } else { byteval = utf_ptr2char(line_ptr + wp->w_cursor.col); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index ddafe1981f..74a5edc0df 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -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. if (!ends_excmd(*arg)) { 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 *oldval; - char_u *newval; - - oldval = vimvars[VV_CMDARG].vv_str; + char_u *oldval = vimvars[VV_CMDARG].vv_str; if (eap == NULL) { xfree(oldval); vimvars[VV_CMDARG].vv_str = oldarg; @@ -9170,14 +9168,18 @@ char_u *set_cmdarg(exarg_T *eap, char_u *oldarg) if (eap->read_edit) len += 7; - if (eap->force_ff != 0) - len += STRLEN(eap->cmd + eap->force_ff) + 6; - if (eap->force_enc != 0) + if (eap->force_ff != 0) { + len += 10; // " ++ff=unix" + } + if (eap->force_enc != 0) { 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) sprintf((char *)newval, " ++bin"); @@ -9189,18 +9191,23 @@ char_u *set_cmdarg(exarg_T *eap, char_u *oldarg) if (eap->read_edit) STRCAT(newval, " ++edit"); - if (eap->force_ff != 0) - sprintf((char *)newval + STRLEN(newval), " ++ff=%s", - eap->cmd + eap->force_ff); - if (eap->force_enc != 0) - sprintf((char *)newval + STRLEN(newval), " ++enc=%s", - eap->cmd + eap->force_enc); - if (eap->bad_char == BAD_KEEP) + if (eap->force_ff != 0) { + snprintf((char *)newval + STRLEN(newval), newval_len, " ++ff=%s", + eap->force_ff == 'u' ? "unix" : + eap->force_ff == 'd' ? "dos" : "mac"); + } + if (eap->force_enc != 0) { + 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"); - else if (eap->bad_char == BAD_DROP) + } else if (eap->bad_char == BAD_DROP) { STRCPY(newval + STRLEN(newval), " ++bad=drop"); - else if (eap->bad_char != 0) - sprintf((char *)newval + STRLEN(newval), " ++bad=%c", eap->bad_char); + } else if (eap->bad_char != 0) { + snprintf((char *)newval + STRLEN(newval), newval_len, " ++bad=%c", + eap->bad_char); + } vimvars[VV_CMDARG].vv_str = newval; return oldval; } diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index 4a40cc54b4..d25d81658c 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -160,7 +160,7 @@ struct exarg { int regname; ///< register name (NUL if none) int force_bin; ///< 0, FORCE_BIN or FORCE_NOBIN 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 bad_char; ///< BAD_KEEP, BAD_DROP or replacement byte int useridx; ///< user command index diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 12bee3ab86..28ecaf684a 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -4373,7 +4373,7 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char_u **errormsgp) if (has_wildcards) { expand_T xpc; - int options = WILD_LIST_NOTFOUND|WILD_ADD_SLASH; + int options = WILD_LIST_NOTFOUND | WILD_NOERROR | WILD_ADD_SLASH; ExpandInit(&xpc); xpc.xp_context = EXPAND_FILES; @@ -4538,6 +4538,21 @@ skip_cmd_arg ( 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. * Return FAIL or OK. @@ -4596,8 +4611,10 @@ static int getargopt(exarg_T *eap) *arg = NUL; 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; + } + eap->force_ff = eap->cmd[eap->force_ff]; } else if (pp == &eap->force_enc) { /* Make 'fileencoding' lower case. */ for (p = eap->cmd + eap->force_enc; *p != NUL; ++p) @@ -4605,15 +4622,9 @@ static int getargopt(exarg_T *eap) } else { /* Check ++bad= argument. Must be a single-byte character, "keep" or * "drop". */ - p = eap->cmd + bad_char_idx; - 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 + if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL) { return FAIL; + } } return OK; @@ -5130,9 +5141,8 @@ static char *get_command_complete(int arg) static void uc_list(char_u *name, size_t name_len) { int i, j; - int found = FALSE; + bool found = false; ucmd_T *cmd; - int len; uint32_t a; // In cmdwin, the alternative buffer should be used. @@ -5151,62 +5161,96 @@ static void uc_list(char_u *name, size_t name_len) continue; } - /* Put out the title first time */ - if (!found) - MSG_PUTS_TITLE(_("\n Name Args Address Complete Definition")); - found = TRUE; + // Put out the title first time + if (!found) { + MSG_PUTS_TITLE(_("\n Name Args Address " + "Complete Definition")); + } + found = true; msg_putchar('\n'); if (got_int) break; - /* Special cases */ - msg_putchar(a & BANG ? '!' : ' '); - msg_putchar(a & REGSTR ? '"' : ' '); - msg_putchar(gap != &ucmds ? 'b' : ' '); - msg_putchar(' '); + // Special cases + int len = 4; + if (a & BANG) { + 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)); len = (int)STRLEN(cmd->uc_name) + 4; do { msg_putchar(' '); - ++len; - } while (len < 16); + len++; + } 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; - /* Arguments */ + // Arguments switch (a & (EXTRA|NOSPC|NEEDARG)) { - case 0: IObuff[len++] = '0'; break; - case (EXTRA): IObuff[len++] = '*'; break; - case (EXTRA|NOSPC): IObuff[len++] = '?'; break; - case (EXTRA|NEEDARG): IObuff[len++] = '+'; break; - case (EXTRA|NOSPC|NEEDARG): IObuff[len++] = '1'; break; + case 0: + IObuff[len++] = '0'; + break; + case (EXTRA): + IObuff[len++] = '*'; + break; + case (EXTRA|NOSPC): + IObuff[len++] = '?'; + break; + case (EXTRA|NEEDARG): + IObuff[len++] = '+'; + break; + case (EXTRA|NOSPC|NEEDARG): + IObuff[len++] = '1'; + break; } do { IObuff[len++] = ' '; - } while (len < 5); + } while (len < 5 - over); - /* Range */ + // Address / Range if (a & (RANGE|COUNT)) { if (a & COUNT) { - /* -count=N */ - sprintf((char *)IObuff + len, "%" PRId64 "c", (int64_t)cmd->uc_def); + // -count=N + snprintf((char *)IObuff + len, IOSIZE, "%" PRId64 "c", + (int64_t)cmd->uc_def); len += (int)STRLEN(IObuff + len); - } else if (a & DFLALL) + } else if (a & DFLALL) { IObuff[len++] = '%'; - else if (cmd->uc_def >= 0) { - /* -range=N */ - sprintf((char *)IObuff + len, "%" PRId64 "", (int64_t)cmd->uc_def); + } else if (cmd->uc_def >= 0) { + // -range=N + snprintf((char *)IObuff + len, IOSIZE, "%" PRId64 "", + (int64_t)cmd->uc_def); len += (int)STRLEN(IObuff + len); - } else + } else { IObuff[len++] = '.'; + } } do { IObuff[len++] = ' '; - } while (len < 11); + } while (len < 9 - over); // Address Type 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 { IObuff[len++] = ' '; - } while (len < 21); + } while (len < 13 - over); // Completion 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 { IObuff[len++] = ' '; - } while (len < 35); + } while (len < 24 - over); IObuff[len] = '\0'; 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) { last_set_msg(cmd->uc_script_ctx); } @@ -5424,9 +5469,8 @@ static void ex_command(exarg_T *eap) end = p; name_len = (int)(end - name); - /* If there is nothing after the name, and no attributes were specified, - * we are listing commands - */ + // If there is nothing after the name, and no attributes were specified, + // we are listing commands p = skipwhite(end); if (!has_attr && ends_excmd(*p)) { uc_list(name, end - name); diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index f6833874ea..1c3c212aef 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -4693,6 +4693,9 @@ ExpandFromContext ( flags |= EW_KEEPALL; if (options & WILD_SILENT) flags |= EW_SILENT; + if (options & WILD_NOERROR) { + flags |= EW_NOERROR; + } if (options & WILD_ALLLINKS) { flags |= EW_ALLLINKS; } diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 84c328f0c4..e5845e0749 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -2032,14 +2032,16 @@ readfile_linenr( * Fill "*eap" to force the 'fileencoding', 'fileformat' and 'binary to be * 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); - eap->force_enc = 14 + (int)STRLEN(buf->b_p_ff); + snprintf((char *)eap->cmd, cmd_len, "e ++enc=%s", buf->b_p_fenc); + eap->force_enc = 8; 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->read_edit = FALSE; diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index d70d04cb4b..0debd39555 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -3361,7 +3361,7 @@ showmap ( msg_putchar(' '); // 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 { msg_putchar(' '); /* padd with blanks */ ++len; @@ -3389,7 +3389,7 @@ showmap ( // as typeahead. char_u *s = vim_strsave(mp->m_str); vim_unescape_csi(s); - msg_outtrans_special(s, FALSE); + msg_outtrans_special(s, false, 0); xfree(s); } if (p_verbose > 0) { diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 922b684120..fa7c39cc65 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -1863,7 +1863,10 @@ errorret: // Avoid giving this message for a recursive call, may happen // when the GUI redraws part of the text. 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--; } goto errorret; diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 18c4f1fff1..a3e0130465 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -868,7 +868,7 @@ static void show_menus_recursive(vimmenu_T *menu, int modes, int depth) if (*menu->strings[bit] == NUL) { msg_puts_attr("<Nop>", HL_ATTR(HLF_8)); } else { - msg_outtrans_special(menu->strings[bit], false); + msg_outtrans_special(menu->strings[bit], false, 0); } } } else { diff --git a/src/nvim/message.c b/src/nvim/message.c index 94729dfd2a..a12e665099 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1521,7 +1521,8 @@ void msg_make(char_u *arg) /// the character/string -- webb int msg_outtrans_special( 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) { @@ -1541,6 +1542,9 @@ int msg_outtrans_special( string = str2special((const char **)&str, from, false); } const int len = vim_strsize((char_u *)string); + if (maxlen > 0 && retval + len >= maxlen) { + break; + } // Highlight special keys msg_puts_attr(string, (len > 1 && (*mb_ptr2len)((char_u *)string) <= 1 diff --git a/src/nvim/option.c b/src/nvim/option.c index 100902897a..478c9a0ff8 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -7294,12 +7294,13 @@ int get_fileformat(buf_T *buf) /// argument. /// /// @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; if (eap != NULL && eap->force_ff != 0) { - c = eap->cmd[eap->force_ff]; + c = eap->force_ff; } else { if ((eap != NULL && eap->force_bin != 0) ? (eap->force_bin == FORCE_BIN) : buf->b_p_bin) { diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 71c6f06ac0..06ffa171ca 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -3845,7 +3845,7 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last) *dirname = NUL; // Add one line for each error - if (old_last == NULL) { + if (old_last == NULL || old_last->qf_next == NULL) { qfp = qfl->qf_start; lnum = 0; } else { diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index c36458930f..e52fd888bd 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -86,7 +86,7 @@ nongui: nolog $(FIXFF) $(SCRIPTS) newtests report @echo 'set $$_exitcode = -1\nrun\nif $$_exitcode != -1\n quit\nend' > .gdbinit report: - $(RUN_VIMTEST) $(NO_INITS) -u NONE -S summarize.vim messages + $(NVIM_PRG) -u NONE $(NO_INITS) -S summarize.vim messages @echo @echo 'Test results:' @cat test_result.log diff --git a/src/nvim/testdir/test49.vim b/src/nvim/testdir/test49.vim index fc79f57d2e..c86fdf25ab 100644 --- a/src/nvim/testdir/test49.vim +++ b/src/nvim/testdir/test49.vim @@ -1,6 +1,6 @@ " Vim script language tests " Author: Servatius Brandt <Servatius.Brandt@fujitsu-siemens.com> -" Last Change: 2019 May 24 +" Last Change: 2019 Oct 08 "------------------------------------------------------------------------------- " Test environment {{{1 @@ -456,7 +456,7 @@ function! ExtraVim(...) " messing up the user's viminfo file. let redirect = a:0 ? \ " -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 'let ExtraVimBegin = " . extra_begin . "'" . \ " -c 'let ExtraVimResult = \"" . resultfile . "\"'" . breakpoints . diff --git a/src/nvim/testdir/test_compiler.vim b/src/nvim/testdir/test_compiler.vim index 40d3cdbdae..6bb602717f 100644 --- a/src/nvim/testdir/test_compiler.vim +++ b/src/nvim/testdir/test_compiler.vim @@ -38,10 +38,11 @@ func Test_compiler() endfunc func Test_compiler_without_arg() - let a=split(execute('compiler')) - call assert_match('^.*runtime/compiler/ant.vim$', a[0]) - call assert_match('^.*runtime/compiler/bcc.vim$', a[1]) - call assert_match('^.*runtime/compiler/xmlwf.vim$', a[-1]) + let runtime = substitute($VIMRUNTIME, '\\', '/', 'g') + let a = split(execute('compiler')) + call assert_match(runtime .. '/compiler/ant.vim$', a[0]) + call assert_match(runtime .. '/compiler/bcc.vim$', a[1]) + call assert_match(runtime .. '/compiler/xmlwf.vim$', a[-1]) endfunc func Test_compiler_completion() diff --git a/src/nvim/testdir/test_plus_arg_edit.vim b/src/nvim/testdir/test_plus_arg_edit.vim index f6d31e7626..e91a6e467a 100644 --- a/src/nvim/testdir/test_plus_arg_edit.vim +++ b/src/nvim/testdir/test_plus_arg_edit.vim @@ -8,3 +8,31 @@ function Test_edit() call delete('Xfile1') call delete('Xfile2') 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 diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index d7b387c2c9..015f771435 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -1510,6 +1510,13 @@ func Test_setqflist_invalid_nr() call setqflist([], ' ', {'nr' : $XXX_DOES_NOT_EXIST}) 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() call XquickfixSetListWithAct('c') call XquickfixSetListWithAct('l') diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim index 94789d6ea3..e5eaa01e92 100644 --- a/src/nvim/testdir/test_spell.vim +++ b/src/nvim/testdir/test_spell.vim @@ -130,20 +130,21 @@ endfunc func Test_spellinfo() throw 'skipped: Nvim does not support enc=latin1' new + let runtime = substitute($VIMRUNTIME, '\\', '/', 'g') 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 - 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 - 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 call assert_match("^\n" . - \ "file: .*/runtime/spell/en.latin1.spl\n" . - \ "file: .*/runtime/spell/en.latin1.spl\n$", execute('spellinfo')) + \ "file: " .. runtime .. "/spell/en.latin1.spl\n" . + \ "file: " .. runtime .. "/spell/en.latin1.spl\n$", execute('spellinfo')) set spell spelllang= call assert_fails('spellinfo', 'E756:') diff --git a/src/nvim/testdir/test_user_func.vim b/src/nvim/testdir/test_user_func.vim index e7a3701386..67701ee3ca 100644 --- a/src/nvim/testdir/test_user_func.vim +++ b/src/nvim/testdir/test_user_func.vim @@ -94,3 +94,7 @@ func Test_user_func() unlet g:retval g:counter enew! endfunc + +func Test_failed_call_in_try() + try | call UnknownFunc() | catch | endtry +endfunc diff --git a/src/nvim/testdir/test_writefile.vim b/src/nvim/testdir/test_writefile.vim index 6066d61af4..56031662a3 100644 --- a/src/nvim/testdir/test_writefile.vim +++ b/src/nvim/testdir/test_writefile.vim @@ -1,4 +1,4 @@ -" Tests for the writefile() function. +" Tests for the writefile() function and some :write commands. func Test_writefile() let f = tempname() @@ -16,6 +16,11 @@ func Test_writefile() call delete(f) 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() call assert_fails('call writefile(["test"], "Xfile", [])', 'E730:') call assert_false(filereadable("Xfile")) diff --git a/src/nvim/tui/terminfo.c b/src/nvim/tui/terminfo.c index 03173afe07..7dfe7ab953 100644 --- a/src/nvim/tui/terminfo.c +++ b/src/nvim/tui/terminfo.c @@ -187,7 +187,7 @@ void terminfo_info_msg(const unibi_term *const ut) msg_printf_attr(0, " %-25s %-10s = ", unibi_name_str(i), unibi_short_name_str(i)); // 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'); } } @@ -214,7 +214,7 @@ void terminfo_info_msg(const unibi_term *const ut) msg_puts("Extended string capabilities:\n"); 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_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'); } } |