Skip to content

fix(form): check if window is valid before closing in cleanup - #532

Open
hey-sebi wants to merge 1 commit into
stevearc:masterfrom
hey-sebi:fix/form-cleanup-invalid-win-id
Open

hey-sebi wants to merge 1 commit into
stevearc:masterfrom
hey-sebi:fix/form-cleanup-invalid-win-id

Conversation

@hey-sebi

Copy link
Copy Markdown

Problem

When submitting a parameter form (Form:submit()), the task callback is executed before self.cleanup(). If the task starts immediately and opens an output dock split (e.g. via open_output with direction = "dock", on_start = "always"), opening the split window can invalidate/close the transient floating form window.

When cleanup() subsequently executes, nvim_win_close(winid, true) fails with an error:

Error executing vim.schedule lua callback: .../lua/overseer/form/utils.lua:345: Invalid window id: 1007
stack traceback:
   [C]: in function 'nvim_win_close'
   .../lua/overseer/form/utils.lua:345: in function 'cleanup'
   .../lua/overseer/form/init.lua:349: in function 'submit'

Solution

Check vim.api.nvim_win_is_valid(winid) before calling nvim_win_close, matching the guard already used in set_layout() and on_win_scrolled().

@github-actions
github-actions Bot requested a review from stevearc October 23, 2026 16:34
@hey-sebi
hey-sebi marked this pull request as ready for review October 23, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant