mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 14:08:32 +00:00
vim-patch:8.2.4591: cursor line not updated when a callback moves the cursor
Problem: Cursor line not updated when a callback moves the cursor.
Solution: Check if the cursor moved. (closes vim/vim#9970)
e7a74d5375
redraw_after_callback() is N/A. Nvim handles timers on the main loop.
This commit is contained in:
@@ -1296,13 +1296,7 @@ static void normal_redraw(NormalState *s)
|
||||
}
|
||||
|
||||
// Might need to update for 'cursorline'.
|
||||
// When 'cursorlineopt' is "screenline" need to redraw always.
|
||||
if (curwin->w_p_cul
|
||||
&& (curwin->w_last_cursorline != curwin->w_cursor.lnum
|
||||
|| (curwin->w_p_culopt_flags & CULOPT_SCRLINE))
|
||||
&& !char_avail()) {
|
||||
redraw_later(curwin, VALID);
|
||||
}
|
||||
check_redraw_cursorline();
|
||||
|
||||
if (VIsual_active) {
|
||||
update_curbuf(INVERTED); // update inverted part
|
||||
|
@@ -737,6 +737,9 @@ static void win_update(win_T *wp, DecorProviders *providers)
|
||||
#define DID_FOLD 3 // updated a folded line
|
||||
int did_update = DID_NONE;
|
||||
linenr_T syntax_last_parsed = 0; // last parsed text line
|
||||
// remember the current w_last_cursorline, it changes when drawing the new
|
||||
// cursor line
|
||||
linenr_T last_cursorline = wp->w_last_cursorline;
|
||||
linenr_T mod_top = 0;
|
||||
linenr_T mod_bot = 0;
|
||||
int save_got_int;
|
||||
@@ -1368,7 +1371,7 @@ static void win_update(win_T *wp, DecorProviders *providers)
|
||||
|| (wp->w_match_head != NULL
|
||||
&& buf->b_mod_xlines != 0)))))
|
||||
|| (wp->w_p_cul && (lnum == wp->w_cursor.lnum
|
||||
|| lnum == wp->w_last_cursorline))) {
|
||||
|| lnum == last_cursorline))) {
|
||||
if (lnum == mod_top) {
|
||||
top_to_mod = false;
|
||||
}
|
||||
@@ -7615,3 +7618,15 @@ win_T *get_win_by_grid_handle(handle_T handle)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/// Check if the cursor moved and 'cursorline' is set. Mark for a VALID redraw
|
||||
/// if needed.
|
||||
void check_redraw_cursorline(void)
|
||||
{
|
||||
// When 'cursorlineopt' is "screenline" need to redraw always.
|
||||
if (curwin->w_p_cul
|
||||
&& (curwin->w_last_cursorline != curwin->w_cursor.lnum
|
||||
|| (curwin->w_p_culopt_flags & CULOPT_SCRLINE))
|
||||
&& !char_avail()) {
|
||||
redraw_later(curwin, VALID);
|
||||
}
|
||||
}
|
||||
|
@@ -268,4 +268,30 @@ END
|
||||
call delete('Xtextfile')
|
||||
endfunc
|
||||
|
||||
func Test_cursorline_callback()
|
||||
CheckScreendump
|
||||
CheckFeature timers
|
||||
|
||||
let lines =<< trim END
|
||||
call setline(1, ['aaaaa', 'bbbbb', 'ccccc', 'ddddd'])
|
||||
set cursorline
|
||||
call cursor(4, 1)
|
||||
|
||||
func Func(timer)
|
||||
call cursor(2, 1)
|
||||
endfunc
|
||||
|
||||
call timer_start(300, 'Func')
|
||||
END
|
||||
call writefile(lines, 'Xcul_timer')
|
||||
|
||||
let buf = RunVimInTerminal('-S Xcul_timer', #{rows: 8})
|
||||
call TermWait(buf, 310)
|
||||
call VerifyScreenDump(buf, 'Test_cursorline_callback_1', {})
|
||||
|
||||
call StopVimInTerminal(buf)
|
||||
call delete('Xcul_timer')
|
||||
endfunc
|
||||
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
@@ -1081,6 +1081,46 @@ describe('CursorLine and CursorLineNr highlights', function()
|
||||
]])
|
||||
end)
|
||||
|
||||
it('is updated if cursor is moved up from timer vim-patch:8.2.4591', function()
|
||||
local screen = Screen.new(50, 8)
|
||||
screen:set_default_attr_ids({
|
||||
[1] = {background = Screen.colors.Gray90}, -- CursorLine
|
||||
[2] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText
|
||||
})
|
||||
screen:attach()
|
||||
exec([[
|
||||
call setline(1, ['aaaaa', 'bbbbb', 'ccccc', 'ddddd'])
|
||||
set cursorline
|
||||
call cursor(4, 1)
|
||||
|
||||
func Func(timer)
|
||||
call cursor(2, 1)
|
||||
endfunc
|
||||
|
||||
call timer_start(300, 'Func')
|
||||
]])
|
||||
screen:expect({grid = [[
|
||||
aaaaa |
|
||||
bbbbb |
|
||||
ccccc |
|
||||
{1:^ddddd }|
|
||||
{2:~ }|
|
||||
{2:~ }|
|
||||
{2:~ }|
|
||||
|
|
||||
]], timeout = 100})
|
||||
screen:expect({grid = [[
|
||||
aaaaa |
|
||||
{1:^bbbbb }|
|
||||
ccccc |
|
||||
ddddd |
|
||||
{2:~ }|
|
||||
{2:~ }|
|
||||
{2:~ }|
|
||||
|
|
||||
]]})
|
||||
end)
|
||||
|
||||
it('with split windows in diff mode', function()
|
||||
local screen = Screen.new(50,12)
|
||||
screen:set_default_attr_ids({
|
||||
|
Reference in New Issue
Block a user