mirror of
https://github.com/neovim/neovim.git
synced 2025-09-26 13:08:33 +00:00
vim-patch:8.1.0448: cursorline not removed when using 'cursorbind'
Problem: Cursorline not removed when using 'cursorbind'. (Justin Keyes)
Solution: Store the last cursor line per window. (closes vim/vim#3488)
4a5abbd613
This commit is contained in:
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user