mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
fix(api): update topline when flushing with nvim__redraw() (#34346)
Problem: nvim__redraw may update the screen with an invalid topline. Solution: Update the topline before calling `update_screen()` (as :redraw does).
This commit is contained in:
@@ -2376,6 +2376,8 @@ void nvim__redraw(Dict(redraw) *opts, Error *err)
|
|||||||
// Redraw pending screen updates when explicitly requested or when determined
|
// Redraw pending screen updates when explicitly requested or when determined
|
||||||
// that it is necessary to properly draw other requested components.
|
// that it is necessary to properly draw other requested components.
|
||||||
if (opts->flush && !cmdpreview) {
|
if (opts->flush && !cmdpreview) {
|
||||||
|
validate_cursor(curwin);
|
||||||
|
update_topline(curwin);
|
||||||
update_screen();
|
update_screen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5674,4 +5674,32 @@ describe('API', function()
|
|||||||
|
|
||||||
n.assert_alive()
|
n.assert_alive()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('nvim__redraw updates topline', function()
|
||||||
|
local screen = Screen.new(40, 8)
|
||||||
|
fn.setline(1, fn.range(100))
|
||||||
|
feed(':call getchar()<CR>')
|
||||||
|
fn.cursor(50, 1)
|
||||||
|
screen:expect([[
|
||||||
|
0 |
|
||||||
|
1 |
|
||||||
|
2 |
|
||||||
|
3 |
|
||||||
|
4 |
|
||||||
|
5 |
|
||||||
|
6 |
|
||||||
|
^:call getchar() |
|
||||||
|
]])
|
||||||
|
api.nvim__redraw({ flush = true })
|
||||||
|
screen:expect([[
|
||||||
|
46 |
|
||||||
|
47 |
|
||||||
|
48 |
|
||||||
|
49 |
|
||||||
|
50 |
|
||||||
|
51 |
|
||||||
|
52 |
|
||||||
|
^:call getchar() |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user