neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit af82f36108ce5bd481ea469cd44df94bff3d0444
parent 22389159f532d67a676bcf0c7c53edb421b8bc37
Author: luukvbaal <luukvbaal@gmail.com>
Date:   Sat,  7 Jun 2025 11:24:24 +0200

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).
Diffstat:
Msrc/nvim/api/vim.c | 2++
Mtest/functional/api/vim_spec.lua | 28++++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c @@ -2376,6 +2376,8 @@ void nvim__redraw(Dict(redraw) *opts, Error *err) // Redraw pending screen updates when explicitly requested or when determined // that it is necessary to properly draw other requested components. if (opts->flush && !cmdpreview) { + validate_cursor(curwin); + update_topline(curwin); update_screen(); } diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua @@ -5674,4 +5674,32 @@ describe('API', function() n.assert_alive() 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)