mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 02:34:59 -07:00
fix(api): use correct buffer for "range" in nvim__redraw (#28614)
This commit is contained in:
parent
01e4a70d66
commit
cf9f002f31
@ -2415,10 +2415,11 @@ void nvim__redraw(Dict(redraw) *opts, Error *err)
|
||||
});
|
||||
linenr_T first = (linenr_T)kv_A(opts->range, 0).data.integer + 1;
|
||||
linenr_T last = (linenr_T)kv_A(opts->range, 1).data.integer;
|
||||
if (last < 0) {
|
||||
last = buf->b_ml.ml_line_count;
|
||||
buf_T *rbuf = win ? win->w_buffer : (buf ? buf : curbuf);
|
||||
if (last == -1) {
|
||||
last = rbuf->b_ml.ml_line_count;
|
||||
}
|
||||
redraw_buf_range_later(win ? win->w_buffer : (buf ? buf : curbuf), first, last);
|
||||
redraw_buf_range_later(rbuf, first, last);
|
||||
}
|
||||
|
||||
if (opts->cursor) {
|
||||
|
@ -5195,28 +5195,27 @@ describe('API', function()
|
||||
})
|
||||
-- valid = true does not draw any lines on its own
|
||||
exec_lua([[
|
||||
lines = 0
|
||||
_G.lines = 0
|
||||
ns = vim.api.nvim_create_namespace('')
|
||||
on_win = function()
|
||||
if do_win then
|
||||
vim.api.nvim_buf_set_extmark(0, ns, 0, 0, { hl_group = 'IncSearch', end_col = 6 })
|
||||
end
|
||||
end
|
||||
vim.api.nvim_set_decoration_provider(ns, {
|
||||
on_win = on_win,
|
||||
on_win = function()
|
||||
if _G.do_win then
|
||||
vim.api.nvim_buf_set_extmark(0, ns, 0, 0, { hl_group = 'IncSearch', end_col = 6 })
|
||||
end
|
||||
end,
|
||||
on_line = function()
|
||||
lines = lines + 1
|
||||
_G.lines = _G.lines + 1
|
||||
end,
|
||||
})
|
||||
]])
|
||||
local lines = exec_lua('return lines')
|
||||
api.nvim__redraw({ buf = 0, valid = true, flush = true })
|
||||
eq(lines, exec_lua('return lines'))
|
||||
eq(lines, exec_lua('return _G.lines'))
|
||||
-- valid = false does
|
||||
api.nvim__redraw({ buf = 0, valid = false, flush = true })
|
||||
neq(lines, exec_lua('return lines'))
|
||||
neq(lines, exec_lua('return _G.lines'))
|
||||
-- valid = true does redraw lines if affected by on_win callback
|
||||
exec_lua('do_win = true')
|
||||
exec_lua('_G.do_win = true')
|
||||
api.nvim__redraw({ buf = 0, valid = true, flush = true })
|
||||
screen:expect({
|
||||
grid = [[
|
||||
@ -5227,5 +5226,8 @@ describe('API', function()
|
||||
13 |
|
||||
]],
|
||||
})
|
||||
-- takes buffer line count from correct buffer with "win" and {0, -1} "range"
|
||||
api.nvim__redraw({ win = 0, range = { 0, -1 } })
|
||||
n.assert_alive()
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user