diff options
-rw-r--r-- | src/nvim/ex_cmds2.c | 2 | ||||
-rw-r--r-- | src/nvim/globals.h | 3 | ||||
-rw-r--r-- | src/nvim/quickfix.c | 125 | ||||
-rw-r--r-- | src/nvim/testdir/test_clientserver.vim | 23 | ||||
-rw-r--r-- | src/nvim/testdir/test_popup.vim | 32 | ||||
-rw-r--r-- | src/nvim/testdir/test_quickfix.vim | 117 | ||||
-rw-r--r-- | src/nvim/testdir/test_quotestar.vim | 21 | ||||
-rw-r--r-- | test/functional/helpers.lua | 9 | ||||
-rw-r--r-- | test/functional/terminal/ex_terminal_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/ui/inccommand_spec.lua | 48 | ||||
-rw-r--r-- | test/functional/ui/wildmode_spec.lua | 18 |
11 files changed, 262 insertions, 142 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index df23d0630a..691ad74100 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -159,6 +159,7 @@ void do_debug(char_u *cmd) redir_off = true; // don't redirect debug commands State = NORMAL; + debug_mode = true; if (!debug_did_msg) { MSG(_("Entering Debug mode. Type \"cont\" to continue.")); @@ -337,6 +338,7 @@ void do_debug(char_u *cmd) msg_scroll = save_msg_scroll; lines_left = (int)(Rows - 1); State = save_State; + debug_mode = false; did_emsg = save_did_emsg; cmd_silent = save_cmd_silent; msg_silent = save_msg_silent; diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 82fc7c1218..ad321963fe 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -655,9 +655,10 @@ EXTERN char_u *fenc_default INIT(= NULL); /// finish_op : When State is NORMAL, after typing the operator and /// before typing the motion command. /// motion_force: Last motion_force from do_pending_operator() +/// debug_mode: Debug mode EXTERN int State INIT(= NORMAL); // This is the current state of the // command interpreter. - +EXTERN bool debug_mode INIT(= false); EXTERN bool finish_op INIT(= false); // true while an operator is pending EXTERN long opcount INIT(= 0); // count for pending operator EXTERN int motion_force INIT(=0); // motion force for pending operator diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 1eb616bca7..2635f1d38a 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -77,6 +77,7 @@ struct qfline_S { * There is a stack of error lists. */ #define LISTCOUNT 10 +#define INVALID_QFIDX (-1) /// Quickfix/Location list definition /// @@ -1862,7 +1863,7 @@ static bool qflist_valid(win_T *wp, unsigned int qf_id) return false; } -/// When loading a file from the quickfix, the auto commands may modify it. +/// When loading a file from the quickfix, the autocommands may modify it. /// This may invalidate the current quickfix entry. This function checks /// whether a entry is still present in the quickfix. /// Similar to location list. @@ -2151,7 +2152,9 @@ win_found: // to the location list from the location window if (win->w_llist == NULL) { win->w_llist = ll_ref; - ll_ref->qf_refcount++; + if (ll_ref != NULL) { + ll_ref->qf_refcount++; + } } } else { // Try to find a window that shows the right buffer. @@ -2426,8 +2429,10 @@ void qf_jump(qf_info_T *qi, int dir, int errornr, int forceit) setpcmark(); } - qf_jump_goto_line(qf_ptr->qf_lnum, qf_ptr->qf_col, qf_ptr->qf_viscol, - qf_ptr->qf_pattern); + if (qf_ptr != NULL) { + qf_jump_goto_line(qf_ptr->qf_lnum, qf_ptr->qf_col, qf_ptr->qf_viscol, + qf_ptr->qf_pattern); + } if ((fdo_flags & FDO_QUICKFIX) && old_KeyTyped) foldOpenCursor(); @@ -3405,6 +3410,19 @@ static void qf_list_changed(qf_info_T *qi, int qf_idx) qi->qf_lists[qf_idx].qf_changedtick++; } +/// Return the quickfix/location list number with the given identifier. +/// +/// @returns -1 if list is not found. +static int qf_id2nr(const qf_info_T *const qi, const unsigned qfid) +{ + for (int qf_idx = 0; qf_idx < qi->qf_listcount; qf_idx++) { + if (qi->qf_lists[qf_idx].qf_id == qfid) { + return qf_idx; + } + } + return INVALID_QFIDX; +} + /* * Return TRUE when using ":vimgrep" for ":grep". */ @@ -3491,22 +3509,29 @@ void ex_make(exarg_T *eap) qf_cmdtitle(*eap->cmdlinep), enc); if (wp != NULL) { qi = GET_LOC_LIST(wp); + if (qi == NULL) { + goto cleanup; + } } - if (res >= 0 && qi != NULL) { + if (res >= 0) { qf_list_changed(qi, qi->qf_curlist); } + // Remember the current quickfix list identifier, so that we can + // check for autocommands changing the current quickfix list. + unsigned save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; if (au_name != NULL) { apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, curbuf->b_fname, true, curbuf); - if (qi != NULL && qi->qf_curlist < qi->qf_listcount) { - res = qi->qf_lists[qi->qf_curlist].qf_count; - } else { - res = 0; + } + if (res > 0 && !eap->forceit && qflist_valid(wp, save_qfid)) { + // If autocommands changed the current list, then restore it. + if (qi->qf_lists[qi->qf_curlist].qf_id != save_qfid) { + qi->qf_curlist = qf_id2nr(qi, save_qfid); } + qf_jump(qi, 0, 0, false); // display first error } - if (res > 0 && !eap->forceit) - qf_jump(qi, 0, 0, FALSE); /* display first error */ +cleanup: os_remove((char *)fname); xfree(fname); xfree(cmd); @@ -3854,37 +3879,27 @@ void ex_cfile(exarg_T *eap) qf_cmdtitle(*eap->cmdlinep), enc); if (wp != NULL) { qi = GET_LOC_LIST(wp); + if (qi == NULL) { + return; + } } - if (res >= 0 && qi != NULL) { + if (res >= 0) { qf_list_changed(qi, qi->qf_curlist); } - unsigned save_qfid = 0; - if (qi != NULL) { - save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; - } + unsigned save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; if (au_name != NULL) { apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, false, curbuf); } - // Autocmd might have freed the quickfix/location list. Check whether it is - // still valid - if (qi != NULL && !qflist_valid(wp, save_qfid)) { - return; - } - if (res > 0 && (eap->cmdidx == CMD_cfile || eap->cmdidx == CMD_lfile)) { - qf_jump(qi, 0, 0, eap->forceit); // display first error - } -} - -// Return the quickfix/location list number with the given identifier. -// Returns -1 if list is not found. -static int qf_id2nr(const qf_info_T *const qi, const unsigned qfid) -{ - for (int qf_idx = 0; qf_idx < qi->qf_listcount; qf_idx++) { - if (qi->qf_lists[qf_idx].qf_id == qfid) { - return qf_idx; + // Jump to the first error for a new list and if autocmds didn't free the + // list. + if (res > 0 && (eap->cmdidx == CMD_cfile || eap->cmdidx == CMD_lfile) + && qflist_valid(wp, save_qfid)) { + // If autocommands changed the current list, then restore it + if (qi->qf_lists[qi->qf_curlist].qf_id != save_qfid) { + qi->qf_curlist = qf_id2nr(qi, save_qfid); } + qf_jump(qi, 0, 0, eap->forceit); // display first error } - return -1; } /// Return the vimgrep autocmd name. @@ -4282,6 +4297,11 @@ void ex_vimgrep(exarg_T *eap) goto theend; } + // If autocommands changed the current list, then restore it. + if (qi->qf_lists[qi->qf_curlist].qf_id != save_qfid) { + qi->qf_curlist = qf_id2nr(qi, save_qfid); + } + /* Jump to first match. */ if (qi->qf_lists[qi->qf_curlist].qf_count > 0) { if ((flags & VGR_NOJUMP) == 0) { @@ -4364,7 +4384,7 @@ load_dummy_buffer ( /* need to open the memfile before putting the buffer in a window */ if (ml_open(newbuf) == OK) { - // Make sure this buffer isn't wiped out by auto commands. + // Make sure this buffer isn't wiped out by autocommands. newbuf->b_locked++; // set curwin/curbuf to buf and save a few things aucmd_prepbuf(&aco, newbuf); @@ -5234,6 +5254,7 @@ void ex_cbuffer(exarg_T *eap) buf_T *buf = NULL; qf_info_T *qi = &ql_info; const char *au_name = NULL; + win_T *wp = NULL; switch (eap->cmdidx) { case CMD_cbuffer: @@ -5270,6 +5291,10 @@ void ex_cbuffer(exarg_T *eap) || eap->cmdidx == CMD_lgetbuffer || eap->cmdidx == CMD_laddbuffer) { qi = ll_get_or_alloc_list(curwin); + if (qi == NULL) { + return; + } + wp = curwin; } if (*eap->arg == NUL) @@ -5304,6 +5329,9 @@ void ex_cbuffer(exarg_T *eap) if (res >= 0) { qf_list_changed(qi, qi->qf_curlist); } + // Remember the current quickfix list identifier, so that we can + // check for autocommands changing the current quickfix list. + unsigned save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; if (au_name != NULL) { const buf_T *const curbuf_old = curbuf; apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)au_name, @@ -5314,8 +5342,14 @@ void ex_cbuffer(exarg_T *eap) res = 0; } } - if (res > 0 && (eap->cmdidx == CMD_cbuffer - || eap->cmdidx == CMD_lbuffer)) { + // Jump to the first error for new list and if autocmds didn't + // free the list. + if (res > 0 && (eap->cmdidx == CMD_cbuffer || eap->cmdidx == CMD_lbuffer) + && qflist_valid(wp, save_qfid)) { + // If autocommands changed the current list, then restore it. + if (qi->qf_lists[qi->qf_curlist].qf_id != save_qfid) { + qi->qf_curlist = qf_id2nr(qi, save_qfid); + } qf_jump(qi, 0, 0, eap->forceit); // display first error } } @@ -5330,6 +5364,7 @@ void ex_cexpr(exarg_T *eap) { qf_info_T *qi = &ql_info; const char *au_name = NULL; + win_T *wp = NULL; switch (eap->cmdidx) { case CMD_cexpr: @@ -5364,6 +5399,10 @@ void ex_cexpr(exarg_T *eap) || eap->cmdidx == CMD_lgetexpr || eap->cmdidx == CMD_laddexpr) { qi = ll_get_or_alloc_list(curwin); + if (qi == NULL) { + return; + } + wp = curwin; } /* Evaluate the expression. When the result is a string or a list we can @@ -5380,14 +5419,22 @@ void ex_cexpr(exarg_T *eap) if (res >= 0) { qf_list_changed(qi, qi->qf_curlist); } + // Remember the current quickfix list identifier, so that we can + // check for autocommands changing the current quickfix list. + unsigned save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; if (au_name != NULL) { apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)au_name, curbuf->b_fname, true, curbuf); } + // Jump to the first error for a new list and if autocmds didn't + // free the list. if (res > 0 && (eap->cmdidx == CMD_cexpr || eap->cmdidx == CMD_lexpr) - && qi == GET_LOC_LIST(curwin)) { - // Jump to the first error if autocmds didn't free the list. + && qflist_valid(wp, save_qfid)) { + // If autocommands changed the current list, then restore it. + if (qi->qf_lists[qi->qf_curlist].qf_id != save_qfid) { + qi->qf_curlist = qf_id2nr(qi, save_qfid); + } qf_jump(qi, 0, 0, eap->forceit); } } else { diff --git a/src/nvim/testdir/test_clientserver.vim b/src/nvim/testdir/test_clientserver.vim index 46ac59b3b1..f03a6903c1 100644 --- a/src/nvim/testdir/test_clientserver.vim +++ b/src/nvim/testdir/test_clientserver.vim @@ -27,12 +27,8 @@ func Test_client_server() let name = 'XVIMTEST' let cmd .= ' --servername ' . name - let g:job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'}) - call WaitFor('job_status(g:job) == "run"') - if job_status(g:job) != 'run' - call assert_report('Cannot run the Vim server') - return - endif + let job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'}) + call WaitFor({-> job_status(job) == "run"}) " Takes a short while for the server to be active. " When using valgrind it takes much longer. @@ -83,7 +79,7 @@ func Test_client_server() call remote_send(name, ":call server2client(expand('<client>'), 'another')\<CR>", 'g:myserverid') let peek_result = 'nothing' let r = remote_peek(g:myserverid, 'peek_result') - " unpredictable whether the result is already avaialble. + " unpredictable whether the result is already available. if r > 0 call assert_equal('another', peek_result) elseif r == 0 @@ -97,11 +93,14 @@ func Test_client_server() call assert_equal('another', remote_read(g:myserverid, 2)) call remote_send(name, ":qa!\<CR>") - call WaitFor('job_status(g:job) == "dead"') - if job_status(g:job) != 'dead' - call assert_report('Server did not exit') - call job_stop(g:job, 'kill') - endif + try + call WaitFor({-> job_status(job) == "dead"}) + finally + if job_status(job) != 'dead' + call assert_report('Server did not exit') + call job_stop(job, 'kill') + endif + endtry endfunc " Uncomment this line to get a debugging log diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim index 0027a0a52e..162df4b76e 100644 --- a/src/nvim/testdir/test_popup.vim +++ b/src/nvim/testdir/test_popup.vim @@ -669,27 +669,31 @@ func Test_popup_and_window_resize() if h < 15 return endif - let g:buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile'], {'term_rows': h / 3}) - call term_sendkeys(g:buf, (h / 3 - 1)."o\<esc>") - call term_wait(g:buf, 200) - call term_sendkeys(g:buf, "Gi\<c-x>") - call term_sendkeys(g:buf, "\<c-v>") - call term_wait(g:buf, 100) + let rows = h / 3 + let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile'], {'term_rows': rows}) + call term_sendkeys(buf, (h / 3 - 1) . "o\<esc>") + " Wait for the nested Vim to exit insert mode, where it will show the ruler. + " Need to trigger a redraw. + call WaitFor({-> execute("redraw") == "" && term_getline(buf, rows) =~ '\<' . rows . ',.*Bot'}) + + call term_sendkeys(buf, "Gi\<c-x>") + call term_sendkeys(buf, "\<c-v>") + call term_wait(buf, 100) " popup first entry "!" must be at the top - call WaitFor('term_getline(g:buf, 1) =~ "^!"') - call assert_match('^!\s*$', term_getline(g:buf, 1)) + call WaitFor({-> term_getline(buf, 1) =~ "^!"}) + call assert_match('^!\s*$', term_getline(buf, 1)) exe 'resize +' . (h - 1) - call term_wait(g:buf, 100) + call term_wait(buf, 100) redraw! " popup shifted down, first line is now empty - call WaitFor('term_getline(g:buf, 1) == ""') - call assert_equal('', term_getline(g:buf, 1)) + call WaitFor({-> term_getline(buf, 1) == ""}) + call assert_equal('', term_getline(buf, 1)) sleep 100m " popup is below cursor line and shows first match "!" - call WaitFor('term_getline(g:buf, term_getcursor(g:buf)[0] + 1) =~ "^!"') - call assert_match('^!\s*$', term_getline(g:buf, term_getcursor(g:buf)[0] + 1)) + call WaitFor({-> term_getline(buf, term_getcursor(buf)[0] + 1) =~ "^!"}) + call assert_match('^!\s*$', term_getline(buf, term_getcursor(buf)[0] + 1)) " cursor line also shows ! - call assert_match('^!\s*$', term_getline(g:buf, term_getcursor(g:buf)[0])) + call assert_match('^!\s*$', term_getline(buf, term_getcursor(buf)[0])) bwipe! endfunc diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 1072c51aa2..90abb30da1 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -3387,17 +3387,128 @@ func Test_filter_clist() \ split(execute('filter /pat1/ clist'), "\n")) endfunc -func Test_setloclist_in_aucmd() +" Test for an autocmd freeing the quickfix/location list when cexpr/lexpr is +" running +func Xexpr_acmd_freelist(cchar) + call s:setup_commands(a:cchar) + " This was using freed memory. augroup nasty - au * * call setloclist(0, [], 'f') + au * * call g:Xsetlist([], 'f') augroup END - lexpr "x" + Xexpr "x" augroup nasty au! augroup END endfunc +func Test_cexpr_acmd_freelist() + call Xexpr_acmd_freelist('c') + call Xexpr_acmd_freelist('l') +endfunc + +" Test for commands that create a new quickfix/location list and jump to the +" first error automatically. +func Xjumpto_first_error_test(cchar) + call s:setup_commands(a:cchar) + + call s:create_test_file('Xtestfile1') + call s:create_test_file('Xtestfile2') + let l = ['Xtestfile1:2:Line2', 'Xtestfile2:4:Line4'] + + " Test for cexpr/lexpr + enew + Xexpr l + call assert_equal('Xtestfile1', bufname('')) + call assert_equal(2, line('.')) + + " Test for cfile/lfile + enew + call writefile(l, 'Xerr') + Xfile Xerr + call assert_equal('Xtestfile1', bufname('')) + call assert_equal(2, line('.')) + + " Test for cbuffer/lbuffer + edit Xerr + Xbuffer + call assert_equal('Xtestfile1', bufname('')) + call assert_equal(2, line('.')) + + call delete('Xerr') + call delete('Xtestfile1') + call delete('Xtestfile2') +endfunc + +func Test_jumpto_first_error() + call Xjumpto_first_error_test('c') + call Xjumpto_first_error_test('l') +endfunc + +" Test for a quickfix autocmd changing the quickfix/location list before +" jumping to the first error in the new list. +func Xautocmd_changelist(cchar) + call s:setup_commands(a:cchar) + + " Test for cfile/lfile + call s:create_test_file('Xtestfile1') + call s:create_test_file('Xtestfile2') + Xexpr 'Xtestfile1:2:Line2' + autocmd QuickFixCmdPost * Xolder + call writefile(['Xtestfile2:4:Line4'], 'Xerr') + Xfile Xerr + call assert_equal('Xtestfile2', bufname('')) + call assert_equal(4, line('.')) + autocmd! QuickFixCmdPost + + " Test for cbuffer/lbuffer + call g:Xsetlist([], 'f') + Xexpr 'Xtestfile1:2:Line2' + autocmd QuickFixCmdPost * Xolder + call writefile(['Xtestfile2:4:Line4'], 'Xerr') + edit Xerr + Xbuffer + call assert_equal('Xtestfile2', bufname('')) + call assert_equal(4, line('.')) + autocmd! QuickFixCmdPost + + " Test for cexpr/lexpr + call g:Xsetlist([], 'f') + Xexpr 'Xtestfile1:2:Line2' + autocmd QuickFixCmdPost * Xolder + Xexpr 'Xtestfile2:4:Line4' + call assert_equal('Xtestfile2', bufname('')) + call assert_equal(4, line('.')) + autocmd! QuickFixCmdPost + + " Test for grep/lgrep + call g:Xsetlist([], 'f') + Xexpr 'Xtestfile1:2:Line2' + autocmd QuickFixCmdPost * Xolder + silent Xgrep Line5 Xtestfile2 + call assert_equal('Xtestfile2', bufname('')) + call assert_equal(5, line('.')) + autocmd! QuickFixCmdPost + + " Test for vimgrep/lvimgrep + call g:Xsetlist([], 'f') + Xexpr 'Xtestfile1:2:Line2' + autocmd QuickFixCmdPost * Xolder + silent Xvimgrep Line5 Xtestfile2 + call assert_equal('Xtestfile2', bufname('')) + call assert_equal(5, line('.')) + autocmd! QuickFixCmdPost + + call delete('Xerr') + call delete('Xtestfile1') + call delete('Xtestfile2') +endfunc + +func Test_autocmd_changelist() + call Xautocmd_changelist('c') + call Xautocmd_changelist('l') +endfunc + " Tests for the "CTRL-W <CR>" command. func Xview_result_split_tests(cchar) call s:setup_commands(a:cchar) diff --git a/src/nvim/testdir/test_quotestar.vim b/src/nvim/testdir/test_quotestar.vim index 3ce1a84281..3a8fdef3a3 100644 --- a/src/nvim/testdir/test_quotestar.vim +++ b/src/nvim/testdir/test_quotestar.vim @@ -60,12 +60,8 @@ func Do_test_quotestar_for_x11() call assert_notmatch(name, serverlist()) let cmd .= ' --servername ' . name - let g:job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'}) - call WaitFor('job_status(g:job) == "run"') - if job_status(g:job) != 'run' - call assert_report('Cannot run the Vim server') - return '' - endif + let job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'}) + call WaitFor({-> job_status(job) == "run"}) " Takes a short while for the server to be active. call WaitFor('serverlist() =~ "' . name . '"') @@ -123,11 +119,14 @@ func Do_test_quotestar_for_x11() endif call remote_send(name, ":qa!\<CR>") - call WaitFor('job_status(g:job) == "dead"') - if job_status(g:job) != 'dead' - call assert_report('Server did not exit') - call job_stop(g:job, 'kill') - endif + try + call WaitFor({-> job_status(job) == "dead"}) + finally + if job_status(job) != 'dead' + call assert_report('Server did not exit') + call job_stop(job, 'kill') + endif + endtry return '' endfunc diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 2f76f24d84..73f3c4c917 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -302,6 +302,10 @@ end local function nvim_feed(input) while #input > 0 do local written = module.request('nvim_input', input) + if written == nil then + module.assert_alive() + error('nvim_input returned nil (Nvim process terminated?)') + end input = input:sub(written + 1) end end @@ -586,6 +590,11 @@ function module.expect_any(contents) return ok(nil ~= string.find(module.curbuf_contents(), contents, 1, true)) end +-- Checks that the Nvim session did not terminate. +function module.assert_alive() + eq(2, module.eval('1+1')) +end + local function do_rmdir(path) if lfs.attributes(path, 'mode') ~= 'directory' then return -- Don't complain. diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index 591e6340cf..b0019d2d37 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -27,11 +27,7 @@ describe(':terminal', function() echomsg "msg3" ]]) -- Invoke a command that emits frequent terminal activity. - if iswin() then - feed_command([[terminal for /L \%I in (1,0,2) do echo \%I]]) - else - feed_command([[terminal while true; do echo X; done]]) - end + feed([[:terminal "]]..nvim_dir..[[/shell-test" REP 9999 !terminal_output!<cr>]]) feed([[<C-\><C-N>]]) wait() -- Wait for some terminal activity. diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 238cc368da..351c4b4bcf 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -16,8 +16,8 @@ local retry = helpers.retry local source = helpers.source local wait = helpers.wait local nvim = helpers.nvim -local iswin = helpers.iswin local sleep = helpers.sleep +local nvim_dir = helpers.nvim_dir local default_text = [[ Inc substitution on @@ -2555,56 +2555,18 @@ it(':substitute with inccommand during :terminal activity', function() clear() command("set cmdwinheight=3") - if iswin() then - feed([[:terminal for /L \%I in (1,1,5000) do @(echo xxx & echo xxx & echo xxx)<cr>]]) - else - feed([[:terminal for i in $(seq 1 5000); do printf 'xxx\nxxx\nxxx\n'; done<cr>]]) - end + feed([[:terminal "]]..nvim_dir..[[/shell-test" REP 5000 xxx<cr>]]) command('file term') + feed('G') -- Follow :terminal output. command('new') common_setup(screen, 'split', 'foo bar baz\nbar baz fox\nbar foo baz') command('wincmd =') - -- Wait for terminal output. - screen:expect([[ - bar baz fox | - bar foo ba^z | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {11:[No Name] [+] }| - xxx | - xxx | - xxx | - xxx | - xxx | - xxx | - {10:term }| - | - ]]) - feed('gg') feed(':%s/foo/ZZZ') sleep(20) -- Allow some terminal activity. - screen:expect([[ - {12:ZZZ} bar baz | - bar baz fox | - bar {12:ZZZ} baz | - {15:~ }| - {15:~ }| - {15:~ }| - {11:[No Name] [+] }| - xxx | - xxx | - {10:term }| - |1| {12:ZZZ} bar baz | - |3| bar {12:ZZZ} baz | - {15:~ }| - {10:[Preview] }| - :%s/foo/ZZZ^ | - ]]) - + helpers.wait() + screen:expect_unchanged() end) end) diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 914256224f..738466ae2b 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -7,6 +7,7 @@ local funcs = helpers.funcs local eq = helpers.eq local eval = helpers.eval local retry = helpers.retry +local nvim_dir = helpers.nvim_dir describe("'wildmenu'", function() local screen @@ -83,13 +84,8 @@ describe("'wildmenu'", function() it('is preserved during :terminal activity', function() command('set wildmenu wildmode=full') command('set scrollback=4') - if iswin() then - feed([[:terminal for /L \%I in (1,1,5000) do @(echo foo & echo foo & echo foo)<cr>]]) - else - feed([[:terminal for i in $(seq 1 5000); do printf 'foo\nfoo\nfoo\n'; sleep 0.1; done<cr>]]) - end - - feed([[<C-\><C-N>gg]]) + feed([[:terminal "]]..nvim_dir..[[/shell-test" REP 5000 !terminal_output!<cr>]]) + feed('G') -- Follow :terminal output. feed([[:sign <Tab>]]) -- Invoke wildmenu. -- NB: in earlier versions terminal output was redrawn during cmdline mode. -- For now just assert that the screen remains unchanged. @@ -114,13 +110,7 @@ describe("'wildmenu'", function() -- Exiting cmdline should show the buffer. feed([[<C-\><C-N>]]) - screen:expect([[ - ^foo | - foo | - foo | - foo | - | - ]]) + screen:expect{any=[[!terminal_output!]]} end) it('ignores :redrawstatus called from a timer #7108', function() |