Skip to content

Commit

Permalink
fix(api): nvim_win_set_cursor() redraw cursorcolumn for non-current…
Browse files Browse the repository at this point in the history
… window

fix #19063
this fixes the cursorcolumn not being redrawn for non-current windows in `nvim_win_set_cursor()`
  • Loading branch information
Jlll1 committed Nov 15, 2022
1 parent 736c36c commit 99fbd16
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/nvim/api/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ void nvim_win_set_cursor(Window window, ArrayOf(Integer, 2) pos, Error *err)
// make sure cursor is in visible range even if win != curwin
update_topline_win(win);

redraw_later(win, UPD_VALID);
// Make sure cursorcolumn and cursorline are updated even if the win != curwin
check_cursor_moved(win);
curs_columns(win, true);

redraw_later(win, UPD_NOT_VALID);
win->w_redr_status = true;
}

Expand Down
30 changes: 30 additions & 0 deletions test/functional/api/window_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,36 @@ describe('API/win', function()
|
]])
end)

it('updates cursorcolumn in non-current window', function()
local screen = Screen.new(60, 8)
screen:set_default_attr_ids({
[1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
[2] = {background = Screen.colors.Grey90}, -- CursorColumn
[3] = {bold = true, reverse = true}, -- StatusLine
[4] = {reverse = true}, -- StatusLineNC
})
screen:attach()
command('set cursorcolumn')
insert([[
aaa
bbb
ccc
ddd]])
local oldwin = curwin()
command('vsplit')
window('set_cursor', oldwin, {2, 2})
screen:expect([[
aa{2:a} │aa{2:a} |
bb{2:b} │bbb |
cc{2:c} │cc{2:c} |
dd^d │dd{2:d} |
{1:~ }│{1:~ }|
{1:~ }│{1:~ }|
{3:[No Name] [+] }{4:[No Name] [+] }|
|
]])
end)
end)

describe('{get,set}_height', function()
Expand Down

0 comments on commit 99fbd16

Please sign in to comment.