mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
vim-patch:9.1.0082: Redrawing can be improved when deleting lines with 'cursorline'
Problem: Redrawing can be improved when deleting lines with 'cursorline'.
Solution: Use smarter invalidation and adjustment. Remove unnecessary
UPD_VALID as it is already set at the top of the loop. Make
the test for vim/vim#4862 fail without the fix.
(zeertzjq)
closes: vim/vim#13986
7ce34c9a94
This commit is contained in:
@@ -353,20 +353,19 @@ static void changed_common(buf_T *buf, linenr_T lnum, colnr_T col, linenr_T lnum
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If lines have been added or removed, relative numbering always
|
// If lines have been added or removed, relative numbering always
|
||||||
// requires a redraw.
|
// requires an update even if cursor didn't move.
|
||||||
if (wp->w_p_rnu && xtra != 0) {
|
if (wp->w_p_rnu && xtra != 0) {
|
||||||
wp->w_last_cursor_lnum_rnu = 0;
|
wp->w_last_cursor_lnum_rnu = 0;
|
||||||
redraw_later(wp, UPD_VALID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cursor line highlighting probably need to be updated with
|
if (wp->w_p_cul && wp->w_last_cursorline >= lnum) {
|
||||||
// "UPD_VALID" if it's below the change.
|
if (wp->w_last_cursorline < lnume) {
|
||||||
// If the cursor line is inside the change we need to redraw more.
|
// If 'cursorline' was inside the change, it has already
|
||||||
if (wp->w_p_cul) {
|
// been invalidated in w_lines[] by the loop above.
|
||||||
if (xtra == 0) {
|
wp->w_last_cursorline = 0;
|
||||||
redraw_later(wp, UPD_VALID);
|
} else {
|
||||||
} else if (lnum <= wp->w_last_cursorline) {
|
// If 'cursorline' was below the change, adjust its lnum.
|
||||||
redraw_later(wp, UPD_SOME_VALID);
|
wp->w_last_cursorline += xtra;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -541,7 +541,7 @@ func Test_cursorline_after_yank()
|
|||||||
call writefile([
|
call writefile([
|
||||||
\ 'set cul rnu',
|
\ 'set cul rnu',
|
||||||
\ 'call setline(1, ["","1","2","3",""])',
|
\ 'call setline(1, ["","1","2","3",""])',
|
||||||
\ ], 'Xtest_cursorline_yank')
|
\ ], 'Xtest_cursorline_yank', 'D')
|
||||||
let buf = RunVimInTerminal('-S Xtest_cursorline_yank', {'rows': 8})
|
let buf = RunVimInTerminal('-S Xtest_cursorline_yank', {'rows': 8})
|
||||||
call TermWait(buf)
|
call TermWait(buf)
|
||||||
call term_sendkeys(buf, "Gy3k")
|
call term_sendkeys(buf, "Gy3k")
|
||||||
@@ -552,25 +552,25 @@ func Test_cursorline_after_yank()
|
|||||||
|
|
||||||
" clean up
|
" clean up
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
call delete('Xtest_cursorline_yank')
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" test for issue https://github.com/vim/vim/issues/4862
|
" Test for issue #4862: pasting above 'cursorline' redraws properly.
|
||||||
func Test_put_before_cursorline()
|
func Test_put_before_cursorline()
|
||||||
new
|
new
|
||||||
only!
|
only!
|
||||||
call setline(1, 'A')
|
call setline(1, ['A', 'B', 'C'])
|
||||||
|
call cursor(2, 1)
|
||||||
redraw
|
redraw
|
||||||
let std_attr = screenattr(1, 1)
|
let std_attr = screenattr(2, 1)
|
||||||
set cursorline
|
set cursorline
|
||||||
redraw
|
redraw
|
||||||
let cul_attr = screenattr(1, 1)
|
let cul_attr = screenattr(2, 1)
|
||||||
normal yyP
|
normal yyP
|
||||||
redraw
|
redraw
|
||||||
" Line 1 has cursor so it should be highlighted with CursorLine.
|
" Line 2 has cursor so it should be highlighted with CursorLine.
|
||||||
call assert_equal(cul_attr, screenattr(1, 1))
|
call assert_equal(cul_attr, screenattr(2, 1))
|
||||||
" And CursorLine highlighting from the second line should be gone.
|
" And CursorLine highlighting from line 3 should be gone.
|
||||||
call assert_equal(std_attr, screenattr(2, 1))
|
call assert_equal(std_attr, screenattr(3, 1))
|
||||||
set nocursorline
|
set nocursorline
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
Reference in New Issue
Block a user