diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/buffer_defs.h | 8 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 4 | ||||
-rw-r--r-- | src/nvim/move.c | 16 | ||||
-rw-r--r-- | src/nvim/testdir/runtest.vim | 7 | ||||
-rw-r--r-- | src/nvim/testdir/test_cmdline.vim | 11 | ||||
-rw-r--r-- | src/nvim/testdir/test_diffmode.vim | 27 | ||||
-rw-r--r-- | src/nvim/testdir/test_timers.vim | 35 |
7 files changed, 95 insertions, 13 deletions
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 9ff62a80af..e86eaf010f 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -983,9 +983,11 @@ struct window_S { used to try to stay in the same column for up/down cursor motions. */ - int w_set_curswant; /* If set, then update w_curswant the next - time through cursupdate() to the - current virtual column */ + int w_set_curswant; // If set, then update w_curswant the next + // time through cursupdate() to the + // current virtual column + + linenr_T w_last_cursorline; ///< where last 'cursorline' was drawn // the next seven are used to update the visual part char w_old_visual_mode; ///< last known VIsual_mode diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 247b9175aa..f40131177e 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -510,6 +510,10 @@ static int command_line_check(VimState *state) // completion may switch it on. quit_more = false; // reset after CTRL-D which had a more-prompt + did_emsg = false; // There can't really be a reason why an error + // that occurs while typing a command should + // cause the command not to be executed. + cursorcmd(); // set the cursor on the right spot ui_cursor_shape(); return 1; diff --git a/src/nvim/move.c b/src/nvim/move.c index 442e5d6dff..320f7b7d98 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -96,11 +96,9 @@ static void comp_botline(win_T *wp) set_empty_rows(wp, done); } -static linenr_T last_cursorline = 0; - void reset_cursorline(void) { - last_cursorline = 0; + curwin->w_last_cursorline = 0; } // Redraw when w_cline_row changes and 'relativenumber' or 'cursorline' is set. @@ -114,17 +112,17 @@ static void redraw_for_cursorline(win_T *wp) redraw_win_later(wp, VALID); } if (wp->w_p_cul) { - if (wp->w_redr_type <= VALID && last_cursorline != 0) { - // "last_cursorline" may be set for another window, worst case - // we redraw too much. This is optimized for moving the cursor - // around in the same window. - redrawWinline(wp, last_cursorline, false); + if (wp->w_redr_type <= VALID && wp->w_last_cursorline != 0) { + // "w_last_cursorline" may be outdated, worst case we redraw + // too much. This is optimized for moving the cursor around in + // the current window. + redrawWinline(wp, wp->w_last_cursorline, false); redrawWinline(wp, wp->w_cursor.lnum, false); redraw_win_later(wp, VALID); } else { redraw_win_later(wp, SOME_VALID); } - last_cursorline = wp->w_cursor.lnum; + wp->w_last_cursorline = wp->w_cursor.lnum; } } } diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim index 44c01cfeff..99b2b940d7 100644 --- a/src/nvim/testdir/runtest.vim +++ b/src/nvim/testdir/runtest.vim @@ -67,7 +67,7 @@ lang mess C let v:testing = 1 " Support function: get the alloc ID by name. -function GetAllocId(name) +func GetAllocId(name) exe 'split ' . s:srcdir . '/alloc.h' let top = search('typedef enum') if top == 0 @@ -81,6 +81,11 @@ function GetAllocId(name) return lnum - top - 1 endfunc +func CanRunVimInTerminal() + " Nvim: always false, we use Lua screen-tests instead. + return 0 +endfunc + func RunTheTest(test) echo 'Executing ' . a:test diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index c302948ba3..26f1dcc333 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -334,6 +334,17 @@ func Test_paste_in_cmdline() call feedkeys(":\<C-\>etoupper(getline(1))\<CR>\<C-B>\"\<CR>", 'tx') call assert_equal('"ASDF.X /TMP/SOME VERYLONGWORD A;B-C*D ', @:) bwipe! + + " Error while typing a command used to cause that it was not executed + " in the end. + new + try + call feedkeys(":file \<C-R>%Xtestfile\<CR>", 'tx') + catch /^Vim\%((\a\+)\)\=:E32/ + " ignore error E32 + endtry + call assert_equal("Xtestfile", bufname("%")) + bwipe! endfunc func Test_remove_char_in_cmdline() diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim index 90fd34d93e..afe289b262 100644 --- a/src/nvim/testdir/test_diffmode.vim +++ b/src/nvim/testdir/test_diffmode.vim @@ -588,3 +588,30 @@ func Test_diff_lastline() bwipe! bwipe! endfunc + +func Test_diff_with_cursorline() + if !CanRunVimInTerminal() + return + endif + + call writefile([ + \ 'hi CursorLine ctermbg=red ctermfg=white', + \ 'set cursorline', + \ 'call setline(1, ["foo","foo","foo","bar"])', + \ 'vnew', + \ 'call setline(1, ["bee","foo","foo","baz"])', + \ 'windo diffthis', + \ '2wincmd w', + \ ], 'Xtest_diff_cursorline') + let buf = RunVimInTerminal('-S Xtest_diff_cursorline', {}) + + call VerifyScreenDump(buf, 'Test_diff_with_cursorline_01', {}) + call term_sendkeys(buf, "j") + call VerifyScreenDump(buf, 'Test_diff_with_cursorline_02', {}) + call term_sendkeys(buf, "j") + call VerifyScreenDump(buf, 'Test_diff_with_cursorline_03', {}) + + " clean up + call StopVimInTerminal(buf) + call delete('Xtest_diff_cursorline') +endfunc diff --git a/src/nvim/testdir/test_timers.vim b/src/nvim/testdir/test_timers.vim index 82afeb76c8..da61751bf4 100644 --- a/src/nvim/testdir/test_timers.vim +++ b/src/nvim/testdir/test_timers.vim @@ -172,6 +172,41 @@ func Test_stop_all_in_callback() call assert_equal(0, len(info)) endfunc +func FeedkeysCb(timer) + call feedkeys("hello\<CR>", 'nt') +endfunc + +func InputCb(timer) + call timer_start(10, 'FeedkeysCb') + let g:val = input('?') + call Resume() +endfunc + +func Test_input_in_timer() + let g:val = '' + call timer_start(10, 'InputCb') + call Standby(1000) + call assert_equal('hello', g:val) +endfunc + +func FuncWithCaughtError(timer) + let g:call_count += 1 + try + doesnotexist + catch + " nop + endtry +endfunc + +func Test_timer_catch_error() + let g:call_count = 0 + let timer = timer_start(10, 'FuncWithCaughtError', {'repeat': 4}) + " Timer will not be stopped. + call WaitFor('g:call_count == 4') + sleep 50m + call assert_equal(4, g:call_count) +endfunc + func FeedAndPeek(timer) call test_feedinput('a') call getchar(1) |