Skip to content

fix(sticky_header): use vim.schedule for window close during BufUnload#84

Merged
hat0uma merged 1 commit intomainfrom
fix/close-sticky-header-correctly
Dec 7, 2025
Merged

fix(sticky_header): use vim.schedule for window close during BufUnload#84
hat0uma merged 1 commit intomainfrom
fix/close-sticky-header-correctly

Conversation

@hat0uma
Copy link
Copy Markdown
Owner

@hat0uma hat0uma commented Dec 7, 2025

Summary

  • Fix sticky header window remaining visible after :e! command
  • Use vim.schedule to defer window close operation to avoid Neovim event callback restrictions

Description

When reloading a buffer with :e!, the sticky header window was not being closed properly. This occurred because nvim_win_close was being called during the BufUnload event callback, where certain window operations may be restricted or silently fail.

The fix defers the window close operation using vim.schedule, ensuring it executes in the next event loop iteration when window operations are permitted.

Additionally, M._sticky_header_wins[winid] is now cleared before scheduling the close to prevent any race conditions.

Test plan

  • Open a CSV file with sticky header enabled
  • Scroll down so the sticky header becomes visible
  • Run :e! to reload the buffer
  • Verify the sticky header window is closed

@hat0uma hat0uma merged commit 860bd8c into main Dec 7, 2025
5 checks passed
@hat0uma hat0uma deleted the fix/close-sticky-header-correctly branch December 7, 2025 14:50
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