diff options
-rw-r--r-- | runtime/filetype.vim | 4 | ||||
-rw-r--r-- | runtime/lua/vim/filetype.lua | 2 | ||||
-rwxr-xr-x | scripts/lua2dox_filter | 14 | ||||
-rw-r--r-- | src/nvim/diff.c | 2 | ||||
-rw-r--r-- | src/nvim/eval/funcs.c | 1 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 15 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 20 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 13 | ||||
-rw-r--r-- | src/nvim/terminal.c | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_autocmd.vim | 104 | ||||
-rw-r--r-- | src/nvim/testdir/test_cmdline.vim | 26 | ||||
-rw-r--r-- | src/nvim/testdir/test_edit.vim | 91 | ||||
-rw-r--r-- | src/nvim/testdir/test_ex_mode.vim | 24 | ||||
-rw-r--r-- | src/nvim/testdir/test_excmd.vim | 16 | ||||
-rw-r--r-- | src/nvim/testdir/test_filetype.vim | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_global.vim | 30 | ||||
-rw-r--r-- | src/nvim/window.c | 10 | ||||
-rw-r--r-- | test/functional/legacy/cmdline_spec.lua | 29 | ||||
-rw-r--r-- | test/functional/legacy/ex_mode_spec.lua | 51 | ||||
-rw-r--r-- | test/functional/legacy/global_spec.lua | 51 | ||||
-rw-r--r-- | test/functional/ui/float_spec.lua | 10 |
21 files changed, 394 insertions, 125 deletions
diff --git a/runtime/filetype.vim b/runtime/filetype.vim index f91d7e1929..5a5937a209 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1983,8 +1983,8 @@ au BufRead,BufNewFile *.ttl " Terminfo au BufNewFile,BufRead *.ti setf terminfo -" Terraform -au BufRead,BufNewFile *.tfvars setf terraform +" Terraform variables +au BufRead,BufNewFile *.tfvars setf terraform-vars " TeX au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl setf tex diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 8746f9e294..10eff6598c 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -969,7 +969,7 @@ local extension = { txi = 'texinfo', texinfo = 'texinfo', text = 'text', - tfvars = 'terraform', + tfvars = 'terraform-vars', tla = 'tla', tli = 'tli', toml = 'toml', diff --git a/scripts/lua2dox_filter b/scripts/lua2dox_filter index 8760f12176..22484a807f 100755 --- a/scripts/lua2dox_filter +++ b/scripts/lua2dox_filter @@ -36,22 +36,14 @@ test_executable(){ ##! \brief sets the lua interpreter set_lua(){ - if test -z "${EXE}" - then + if test -z "${EXE}"; then test_executable 'luajit' fi - if test -z "${EXE}" - then - test_executable 'texlua' - fi - - if test -z "${EXE}" - then + if test -z "${EXE}"; then test_executable 'lua' fi - #echo "final EXE=\"${EXE}\"" - } +} ##! \brief makes canonical name of file ##! diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 55d8b7e36b..4ade6072e6 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1423,7 +1423,7 @@ void diff_win_options(win_T *wp, int addbuf) } wp->w_p_fdc_save = vim_strsave(wp->w_p_fdc); } - xfree(wp->w_p_fdc); + free_string_option(wp->w_p_fdc); wp->w_p_fdc = (char_u *)xstrdup("2"); assert(diff_foldcolumn >= 0 && diff_foldcolumn <= 9); snprintf((char *)wp->w_p_fdc, STRLEN(wp->w_p_fdc) + 1, "%d", diff_foldcolumn); diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 7d5404d782..fb59a3da4c 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -4025,6 +4025,7 @@ static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr) "cindent", "cmdline_compl", "cmdline_hist", + "cmdwin", "comments", "conceal", "cscope", diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 11eef0ac70..c65d9359ac 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2725,6 +2725,12 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum // Assume success now retval = OK; + // If the file name was changed, reset the not-edit flag so that ":write" + // works. + if (!other_file) { + curbuf->b_flags &= ~BF_NOTEDITED; + } + /* * Check if we are editing the w_arg_idx file in the argument list. */ @@ -5574,12 +5580,15 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool // Note: We cannot just do `&NameBuff` because it is a statically sized array // so `NameBuff == &NameBuff` according to C semantics. char *buff_list[1] = { (char *)NameBuff }; - if (gen_expand_wildcards(1, (char_u **)buff_list, &filecount, (char_u ***)&files, - EW_FILE|EW_SILENT) == FAIL - || filecount == 0) { + const int res = gen_expand_wildcards(1, (char_u **)buff_list, &filecount, (char_u ***)&files, + EW_FILE|EW_SILENT); + if (res == FAIL || filecount == 0) { if (!got_int) { semsg(_("E151: No match: %s"), NameBuff); } + if (res != FAIL) { + FreeWild(filecount, (char_u **)files); + } return; } diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 0a9285b7fe..ed5c074577 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3271,6 +3271,7 @@ int cmd_exists(const char *const name) // For ":2match" and ":3match" we need to skip the number. ea.cmd = (char *)((*name == '2' || *name == '3') ? name + 1 : name); ea.cmdidx = (cmdidx_T)0; + ea.flags = 0; int full = false; p = find_ex_command(&ea, &full); if (p == NULL) { @@ -3288,6 +3289,7 @@ int cmd_exists(const char *const name) /// "fullcommand" function void f_fullcommand(typval_T *argvars, typval_T *rettv, FunPtr fptr) { + exarg_T ea; char *name = argvars[0].vval.v_string; rettv->v_type = VAR_STRING; @@ -3301,10 +3303,9 @@ void f_fullcommand(typval_T *argvars, typval_T *rettv, FunPtr fptr) } name = skip_range(name, NULL); - exarg_T ea = { - .cmd = (*name == '2' || *name == '3') ? name + 1 : name, - .cmdidx = (cmdidx_T)0, - }; + ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name; + ea.cmdidx = (cmdidx_T)0; + ea.flags = 0; char *p = find_ex_command(&ea, NULL); if (p == NULL || ea.cmdidx == CMD_SIZE) { return; @@ -6788,9 +6789,18 @@ char *get_user_commands(expand_T *xp FUNC_ATTR_UNUSED, int idx) if (idx < buf->b_ucmds.ga_len) { return (char *)USER_CMD_GA(&buf->b_ucmds, idx)->uc_name; } + idx -= buf->b_ucmds.ga_len; if (idx < ucmds.ga_len) { - return (char *)USER_CMD(idx)->uc_name; + char *name = (char *)USER_CMD(idx)->uc_name; + + for (int i = 0; i < buf->b_ucmds.ga_len; i++) { + if (STRCMP(name, USER_CMD_GA(&buf->b_ucmds, i)->uc_name) == 0) { + // global command is overruled by buffer-local one + return ""; + } + } + return name; } return NULL; } diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 3038e7bd04..906e52f183 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -880,6 +880,12 @@ static uint8_t *command_line_enter(int firstc, long count, int indent, bool init found_one = true; } } + + if (*p_tal != NUL) { + redraw_tabline = true; + found_one = true; + } + if (found_one) { redraw_statuslines(); } @@ -1068,7 +1074,8 @@ static int command_line_execute(VimState *state, int key) // Don't ignore it for the input() function. if ((s->c == Ctrl_C) && s->firstc != '@' - && !s->break_ctrl_c + // do clear got_int in Ex mode to avoid infinite Ctrl-C loop + && (!s->break_ctrl_c || exmode_active) && !global_busy) { got_int = false; } @@ -6804,9 +6811,13 @@ static int open_cmdwin(void) // Avoid command-line window first character being concealed. curwin->w_p_cole = 0; + // First go back to the original window. wp = curwin; set_bufref(&bufref, curbuf); win_goto(old_curwin); + + // win_goto() may trigger an autocommand that already closes the + // cmdline window. if (win_valid(wp) && wp != curwin) { win_close(wp, true, false); } diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index be49048aec..73af00b5d1 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -451,7 +451,7 @@ void terminal_enter(void) if (save_curwin == curwin->handle) { // Else: window was closed. curwin->w_p_cul = save_w_p_cul; if (save_w_p_culopt) { - xfree(curwin->w_p_culopt); + free_string_option(curwin->w_p_culopt); curwin->w_p_culopt = save_w_p_culopt; } curwin->w_p_culopt_flags = save_w_p_culopt_flags; @@ -459,7 +459,7 @@ void terminal_enter(void) curwin->w_p_so = save_w_p_so; curwin->w_p_siso = save_w_p_siso; } else if (save_w_p_culopt) { - xfree(save_w_p_culopt); + free_string_option(save_w_p_culopt); } // draw the unfocused cursor diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 438851a0ad..cf14c85d03 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -2851,6 +2851,110 @@ func Test_v_event_readonly() au! TextYankPost endfunc +" Test for ModeChanged pattern +func Test_mode_changes() + let g:index = 0 + let g:mode_seq = ['n', 'i', 'n', 'v', 'V', 'i', 'ix', 'i', 'ic', 'i', 'n', 'no', 'n', 'V', 'v', 's', 'n'] + func! TestMode() + call assert_equal(g:mode_seq[g:index], get(v:event, "old_mode")) + call assert_equal(g:mode_seq[g:index + 1], get(v:event, "new_mode")) + call assert_equal(mode(1), get(v:event, "new_mode")) + let g:index += 1 + endfunc + + au ModeChanged * :call TestMode() + let g:n_to_any = 0 + au ModeChanged n:* let g:n_to_any += 1 + call feedkeys("i\<esc>vVca\<CR>\<C-X>\<C-L>\<esc>ggdG", 'tnix') + + let g:V_to_v = 0 + au ModeChanged V:v let g:V_to_v += 1 + call feedkeys("Vv\<C-G>\<esc>", 'tnix') + call assert_equal(len(filter(g:mode_seq[1:], {idx, val -> val == 'n'})), g:n_to_any) + call assert_equal(1, g:V_to_v) + call assert_equal(len(g:mode_seq) - 1, g:index) + + let g:n_to_i = 0 + au ModeChanged n:i let g:n_to_i += 1 + let g:n_to_niI = 0 + au ModeChanged i:niI let g:n_to_niI += 1 + let g:niI_to_i = 0 + au ModeChanged niI:i let g:niI_to_i += 1 + let g:nany_to_i = 0 + au ModeChanged n*:i let g:nany_to_i += 1 + let g:i_to_n = 0 + au ModeChanged i:n let g:i_to_n += 1 + let g:nori_to_any = 0 + au ModeChanged [ni]:* let g:nori_to_any += 1 + let g:i_to_any = 0 + au ModeChanged i:* let g:i_to_any += 1 + let g:index = 0 + let g:mode_seq = ['n', 'i', 'niI', 'i', 'n'] + call feedkeys("a\<C-O>l\<esc>", 'tnix') + call assert_equal(len(g:mode_seq) - 1, g:index) + call assert_equal(1, g:n_to_i) + call assert_equal(1, g:n_to_niI) + call assert_equal(1, g:niI_to_i) + call assert_equal(2, g:nany_to_i) + call assert_equal(1, g:i_to_n) + call assert_equal(2, g:i_to_any) + call assert_equal(3, g:nori_to_any) + + if has('terminal') + let g:mode_seq += ['c', 'n', 't', 'nt', 'c', 'nt', 'n'] + call feedkeys(":term\<CR>\<C-W>N:bd!\<CR>", 'tnix') + call assert_equal(len(g:mode_seq) - 1, g:index) + call assert_equal(1, g:n_to_i) + call assert_equal(1, g:n_to_niI) + call assert_equal(1, g:niI_to_i) + call assert_equal(2, g:nany_to_i) + call assert_equal(1, g:i_to_n) + call assert_equal(2, g:i_to_any) + call assert_equal(5, g:nori_to_any) + endif + + if has('cmdwin') + let g:n_to_c = 0 + au ModeChanged n:c let g:n_to_c += 1 + let g:c_to_n = 0 + au ModeChanged c:n let g:c_to_n += 1 + let g:mode_seq += ['c', 'n', 'c', 'n'] + call feedkeys("q:\<C-C>\<Esc>", 'tnix') + call assert_equal(len(g:mode_seq) - 1, g:index) + call assert_equal(2, g:n_to_c) + call assert_equal(2, g:c_to_n) + unlet g:n_to_c + unlet g:c_to_n + endif + + au! ModeChanged + delfunc TestMode + unlet! g:mode_seq + unlet! g:index + unlet! g:n_to_any + unlet! g:V_to_v + unlet! g:n_to_i + unlet! g:n_to_niI + unlet! g:niI_to_i + unlet! g:nany_to_i + unlet! g:i_to_n + unlet! g:nori_to_any + unlet! g:i_to_any +endfunc + +func Test_recursive_ModeChanged() + au! ModeChanged * norm 0u + sil! norm + au! ModeChanged +endfunc + +func Test_ModeChanged_starts_visual() + " This was triggering ModeChanged before setting VIsual, causing a crash. + au! ModeChanged * norm 0u + sil! norm + + au! ModeChanged +endfunc func Test_noname_autocmd() augroup test_noname_autocmd_group diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 276bb7fb71..094c6fd8d4 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -704,6 +704,16 @@ func Test_cmdline_complete_user_cmd() delcommand Foo endfunc +func Test_complete_user_cmd() + command FooBar echo 'global' + command -buffer FooBar echo 'local' + call feedkeys(":Foo\<C-A>\<Home>\"\<CR>", 'tx') + call assert_equal('"FooBar', @:) + + delcommand -buffer FooBar + delcommand FooBar +endfunc + func s:ScriptLocalFunction() echo 'yes' endfunc @@ -1846,4 +1856,20 @@ func Test_long_error_message() silent! norm Q00000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 endfunc +func Test_cmdline_redraw_tabline() + CheckRunVimInTerminal + + let lines =<< trim END + set showtabline=2 + autocmd CmdlineEnter * set tabline=foo + END + call writefile(lines, 'Xcmdline_redraw_tabline') + let buf = RunVimInTerminal('-S Xcmdline_redraw_tabline', #{rows: 6}) + call term_sendkeys(buf, ':') + call WaitForAssert({-> assert_match('^foo', term_getline(buf, 1))}) + + call StopVimInTerminal(buf) + call delete('Xcmdline_redraw_tabline') +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index 42c77518e4..a09346a595 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -1811,95 +1811,4 @@ func Test_read_invalid() set encoding=utf-8 endfunc -" Test for ModeChanged pattern -func Test_mode_changes() - let g:index = 0 - let g:mode_seq = ['n', 'i', 'n', 'v', 'V', 'i', 'ix', 'i', 'ic', 'i', 'n', 'no', 'n', 'V', 'v', 's', 'n'] - func! TestMode() - call assert_equal(g:mode_seq[g:index], get(v:event, "old_mode")) - call assert_equal(g:mode_seq[g:index + 1], get(v:event, "new_mode")) - call assert_equal(mode(1), get(v:event, "new_mode")) - let g:index += 1 - endfunc - - au ModeChanged * :call TestMode() - let g:n_to_any = 0 - au ModeChanged n:* let g:n_to_any += 1 - call feedkeys("i\<esc>vVca\<CR>\<C-X>\<C-L>\<esc>ggdG", 'tnix') - - let g:V_to_v = 0 - au ModeChanged V:v let g:V_to_v += 1 - call feedkeys("Vv\<C-G>\<esc>", 'tnix') - call assert_equal(len(filter(g:mode_seq[1:], {idx, val -> val == 'n'})), g:n_to_any) - call assert_equal(1, g:V_to_v) - call assert_equal(len(g:mode_seq) - 1, g:index) - - let g:n_to_i = 0 - au ModeChanged n:i let g:n_to_i += 1 - let g:n_to_niI = 0 - au ModeChanged i:niI let g:n_to_niI += 1 - let g:niI_to_i = 0 - au ModeChanged niI:i let g:niI_to_i += 1 - let g:nany_to_i = 0 - au ModeChanged n*:i let g:nany_to_i += 1 - let g:i_to_n = 0 - au ModeChanged i:n let g:i_to_n += 1 - let g:nori_to_any = 0 - au ModeChanged [ni]:* let g:nori_to_any += 1 - let g:i_to_any = 0 - au ModeChanged i:* let g:i_to_any += 1 - let g:index = 0 - let g:mode_seq = ['n', 'i', 'niI', 'i', 'n'] - call feedkeys("a\<C-O>l\<esc>", 'tnix') - call assert_equal(len(g:mode_seq) - 1, g:index) - call assert_equal(1, g:n_to_i) - call assert_equal(1, g:n_to_niI) - call assert_equal(1, g:niI_to_i) - call assert_equal(2, g:nany_to_i) - call assert_equal(1, g:i_to_n) - call assert_equal(2, g:i_to_any) - call assert_equal(3, g:nori_to_any) - - if has('terminal') - let g:mode_seq += ['c', 'n', 't', 'nt', 'c', 'nt', 'n'] - call feedkeys(":term\<CR>\<C-W>N:bd!\<CR>", 'tnix') - call assert_equal(len(g:mode_seq) - 1, g:index) - call assert_equal(1, g:n_to_i) - call assert_equal(1, g:n_to_niI) - call assert_equal(1, g:niI_to_i) - call assert_equal(2, g:nany_to_i) - call assert_equal(1, g:i_to_n) - call assert_equal(2, g:i_to_any) - call assert_equal(5, g:nori_to_any) - endif - - au! ModeChanged - delfunc TestMode - unlet! g:mode_seq - unlet! g:index - unlet! g:n_to_any - unlet! g:V_to_v - unlet! g:n_to_i - unlet! g:n_to_niI - unlet! g:niI_to_i - unlet! g:nany_to_i - unlet! g:i_to_n - unlet! g:nori_to_any - unlet! g:i_to_any -endfunc - -func Test_recursive_ModeChanged() - au! ModeChanged * norm 0u - sil! norm - au! -endfunc - -func Test_ModeChanged_starts_visual() - " This was triggering ModeChanged before setting VIsual, causing a crash. - au! ModeChanged * norm 0u - sil! norm - - au! ModeChanged -endfunc - " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_ex_mode.vim b/src/nvim/testdir/test_ex_mode.vim index c06d143425..2f734cba26 100644 --- a/src/nvim/testdir/test_ex_mode.vim +++ b/src/nvim/testdir/test_ex_mode.vim @@ -135,6 +135,30 @@ func Test_Ex_global() bwipe! endfunc +" Test for pressing Ctrl-C in :append inside a loop in Ex mode +" This used to hang Vim +func Test_Ex_append_in_loop() + CheckRunVimInTerminal + let buf = RunVimInTerminal('', {'rows': 6}) + + call term_sendkeys(buf, "gQ") + call term_sendkeys(buf, "for i in range(1)\<CR>") + call term_sendkeys(buf, "append\<CR>") + call WaitForAssert({-> assert_match(': append', term_getline(buf, 5))}, 1000) + call term_sendkeys(buf, "\<C-C>") + " Wait for input to be flushed + call term_wait(buf) + call term_sendkeys(buf, "foo\<CR>") + call WaitForAssert({-> assert_match('foo', term_getline(buf, 5))}, 1000) + call term_sendkeys(buf, ".\<CR>") + call WaitForAssert({-> assert_match('.', term_getline(buf, 5))}, 1000) + call term_sendkeys(buf, "endfor\<CR>") + call term_sendkeys(buf, "vi\<CR>") + call WaitForAssert({-> assert_match('foo', term_getline(buf, 1))}, 1000) + + call StopVimInTerminal(buf) +endfunc + " In Ex-mode, a backslash escapes a newline func Test_Ex_escape_enter() call feedkeys("gQlet l = \"a\\\<kEnter>b\"\<cr>vi\<cr>", 'xt') diff --git a/src/nvim/testdir/test_excmd.vim b/src/nvim/testdir/test_excmd.vim index f844999d8d..dac7a6989d 100644 --- a/src/nvim/testdir/test_excmd.vim +++ b/src/nvim/testdir/test_excmd.vim @@ -696,5 +696,21 @@ func Test_using_zero_in_range() bwipe! endfunc +" Test :write after changing name with :file and loading it with :edit +func Test_write_after_rename() + call writefile(['text'], 'Xfile') + + enew + file Xfile + call assert_fails('write', 'E13: File exists (add ! to override)') + + " works OK after ":edit" + edit + write + + call delete('Xfile') + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index cf029af51e..53f8d4f3ef 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -548,7 +548,7 @@ let s:filename_checks = { \ 'template': ['file.tmpl'], \ 'teraterm': ['file.ttl'], \ 'terminfo': ['file.ti'], - \ 'terraform': ['file.tfvars'], + \ 'terraform-vars': ['file.tfvars'], \ 'tex': ['file.latex', 'file.sty', 'file.dtx', 'file.ltx', 'file.bbl'], \ 'texinfo': ['file.texinfo', 'file.texi', 'file.txi'], \ 'texmf': ['texmf.cnf'], diff --git a/src/nvim/testdir/test_global.vim b/src/nvim/testdir/test_global.vim index feddf85346..947f7efc7c 100644 --- a/src/nvim/testdir/test_global.vim +++ b/src/nvim/testdir/test_global.vim @@ -1,4 +1,7 @@ +" Test for :global and :vglobal + source check.vim +source term_util.vim func Test_yank_put_clipboard() new @@ -82,4 +85,31 @@ func Test_wrong_delimiter() call assert_fails('g x^bxd', 'E146:') endfunc +" Test for interrupting :global using Ctrl-C +func Test_interrupt_global() + CheckRunVimInTerminal + let lines =<< trim END + cnoremap ; <Cmd>sleep 10<CR> + call setline(1, repeat(['foo'], 5)) + END + call writefile(lines, 'Xtest_interrupt_global') + let buf = RunVimInTerminal('-S Xtest_interrupt_global', {'rows': 6}) + + call term_sendkeys(buf, ":g/foo/norm :\<C-V>;\<CR>") + " Wait for :sleep to start + call term_wait(buf) + call term_sendkeys(buf, "\<C-C>") + call WaitForAssert({-> assert_match('Interrupted', term_getline(buf, 6))}, 1000) + + " Also test in Ex mode + call term_sendkeys(buf, "gQg/foo/norm :\<C-V>;\<CR>") + " Wait for :sleep to start + call term_wait(buf) + call term_sendkeys(buf, "\<C-C>") + call WaitForAssert({-> assert_match('Interrupted', term_getline(buf, 5))}, 1000) + + call StopVimInTerminal(buf) + call delete('Xtest_interrupt_global') +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/window.c b/src/nvim/window.c index 97ca45662e..b43378aef2 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -726,31 +726,31 @@ void win_set_minimal_style(win_T *wp) wp->w_p_fcs = ((*old == NUL) ? (char_u *)xstrdup("eob: ") : concat_str(old, (char_u *)",eob: ")); - xfree(old); + free_string_option(old); } if (wp->w_hl_ids[HLF_EOB] != -1) { char_u *old = wp->w_p_winhl; wp->w_p_winhl = ((*old == NUL) ? (char_u *)xstrdup("EndOfBuffer:") : concat_str(old, (char_u *)",EndOfBuffer:")); - xfree(old); + free_string_option(old); } // signcolumn: use 'auto' if (wp->w_p_scl[0] != 'a' || STRLEN(wp->w_p_scl) >= 8) { - xfree(wp->w_p_scl); + free_string_option(wp->w_p_scl); wp->w_p_scl = (char_u *)xstrdup("auto"); } // foldcolumn: use '0' if (wp->w_p_fdc[0] != '0') { - xfree(wp->w_p_fdc); + free_string_option(wp->w_p_fdc); wp->w_p_fdc = (char_u *)xstrdup("0"); } // colorcolumn: cleared if (wp->w_p_cc != NULL && *wp->w_p_cc != NUL) { - xfree(wp->w_p_cc); + free_string_option(wp->w_p_cc); wp->w_p_cc = (char_u *)xstrdup(""); } } diff --git a/test/functional/legacy/cmdline_spec.lua b/test/functional/legacy/cmdline_spec.lua index d8d849271b..cf02636890 100644 --- a/test/functional/legacy/cmdline_spec.lua +++ b/test/functional/legacy/cmdline_spec.lua @@ -3,11 +3,12 @@ local Screen = require('test.functional.ui.screen') local clear = helpers.clear local feed = helpers.feed local feed_command = helpers.feed_command -local source = helpers.source +local exec = helpers.exec describe('cmdline', function() before_each(clear) + -- oldtest: Test_cmdlineclear_tabenter() it('is cleared when switching tabs', function() local screen = Screen.new(30, 10) screen:attach() @@ -91,10 +92,11 @@ describe('cmdline', function() ]]) end) + -- oldtest: Test_verbose_option() it('prints every executed Ex command if verbose >= 16', function() local screen = Screen.new(60, 12) screen:attach() - source([[ + exec([[ command DoSomething echo 'hello' |set ts=4 |let v = '123' |echo v call feedkeys("\r", 't') " for the hit-enter prompt set verbose=20 @@ -115,4 +117,27 @@ describe('cmdline', function() Press ENTER or type command to continue^ | ]]) end) + + -- oldtest: Test_cmdline_redraw_tabline() + it('tabline is redrawn on entering cmdline', function() + local screen = Screen.new(30, 6) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {reverse = true}, -- TabLineFill + }) + screen:attach() + exec([[ + set showtabline=2 + autocmd CmdlineEnter * set tabline=foo + ]]) + feed(':') + screen:expect([[ + {1:foo }| + | + {0:~ }| + {0:~ }| + {0:~ }| + :^ | + ]]) + end) end) diff --git a/test/functional/legacy/ex_mode_spec.lua b/test/functional/legacy/ex_mode_spec.lua index 98f113bbd0..a8f54c6939 100644 --- a/test/functional/legacy/ex_mode_spec.lua +++ b/test/functional/legacy/ex_mode_spec.lua @@ -6,6 +6,7 @@ local eq = helpers.eq local eval = helpers.eval local feed = helpers.feed local meths = helpers.meths +local sleep = helpers.sleep before_each(clear) @@ -122,4 +123,54 @@ describe('Ex mode', function() | ]]) end) + + it('pressing Ctrl-C in :append inside a loop in Ex mode does not hang', function() + local screen = Screen.new(60, 6) + screen:set_default_attr_ids({ + [0] = {bold = true, reverse = true}, -- MsgSeparator + [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + }) + screen:attach() + feed('gQ') + feed('for i in range(1)<CR>') + feed('append<CR>') + screen:expect([[ + {0: }| + Entering Ex mode. Type "visual" to go to Normal mode. | + :for i in range(1) | + | + : append | + ^ | + ]]) + feed('<C-C>') + sleep(10) -- Wait for input to be flushed + feed('foo<CR>') + screen:expect([[ + Entering Ex mode. Type "visual" to go to Normal mode. | + :for i in range(1) | + | + : append | + foo | + ^ | + ]]) + feed('.<CR>') + screen:expect([[ + :for i in range(1) | + | + : append | + foo | + . | + : ^ | + ]]) + feed('endfor<CR>') + feed('vi<CR>') + screen:expect([[ + ^foo | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end) end) diff --git a/test/functional/legacy/global_spec.lua b/test/functional/legacy/global_spec.lua new file mode 100644 index 0000000000..9f4528530c --- /dev/null +++ b/test/functional/legacy/global_spec.lua @@ -0,0 +1,51 @@ +local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') +local clear = helpers.clear +local exec = helpers.exec +local feed = helpers.feed +local sleep = helpers.sleep + +before_each(clear) + +describe(':global', function() + -- oldtest: Test_interrupt_global() + it('can be interrupted using Ctrl-C in cmdline mode vim-patch:9.0.0082', function() + local screen = Screen.new(75, 6) + screen:set_default_attr_ids({ + [0] = {bold = true, reverse = true}, -- MsgSeparator + [1] = {background = Screen.colors.Red, foreground = Screen.colors.White}, -- ErrorMsg + }) + screen:attach() + + exec([[ + set nohlsearch noincsearch + cnoremap ; <Cmd>sleep 10<CR> + call setline(1, repeat(['foo'], 5)) + ]]) + + feed(':g/foo/norm :<C-V>;<CR>') + sleep(10) -- Wait for :sleep to start + feed('<C-C>') + screen:expect([[ + ^foo | + foo | + foo | + foo | + foo | + {1:Interrupted} | + ]]) + + -- Also test in Ex mode + feed('gQg/foo/norm :<C-V>;<CR>') + sleep(10) -- Wait for :sleep to start + feed('<C-C>') + screen:expect([[ + {0: }| + Entering Ex mode. Type "visual" to go to Normal mode. | + :g/foo/norm :; | + | + {1:Interrupted} | + :^ | + ]]) + end) +end) diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 50247ed214..5967b630f6 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -18,6 +18,7 @@ local run = helpers.run local pcall_err = helpers.pcall_err local tbl_contains = global_helpers.tbl_contains local curbuf, curwin, curtab = helpers.curbuf, helpers.curwin, helpers.curtab +local NIL = helpers.NIL describe('float window', function() before_each(function() @@ -420,6 +421,15 @@ describe('float window', function() eq(winids, eval('winids')) end) + it("no segfault when setting minimal style after clearing local 'fillchars' #19510", function() + local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1} + local float_win = meths.open_win(0, true, float_opts) + meths.win_set_option(float_win, 'fillchars', NIL) + float_opts.style = 'minimal' + meths.win_set_config(float_win, float_opts) + assert_alive() + end) + describe('with only one tabpage,', function() local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1} local old_buf, old_win |