fix: defer TabClosed cleanup to prevent window-switching error#341
Open
idmyn wants to merge 1 commit intoesmuellert:mainfrom
Open
fix: defer TabClosed cleanup to prevent window-switching error#341idmyn wants to merge 1 commit intoesmuellert:mainfrom
idmyn wants to merge 1 commit intoesmuellert:mainfrom
Conversation
The TabClosed autocmd runs cleanup_diff synchronously, which calls welcome_window.apply_opts, which sets window options via vim.wo. This requires switching windows internally, which is forbidden during TabClosed. Wrapping in vim.schedule defers the cleanup until after the event, matching the existing pattern used by the WinClosed handler. Fixes "Problem while switching windows" error when using open_in_prev_tab with close_on_open_in_prev_tab enabled.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi there - very nice plugin!
I hit this error when running
open_in_prev_tabwithclose_on_open_in_prev_tab = trueAnd amp fixed it with this diff. It solved the problem for but I'm new to nvim/lua so I have absolutely no idea if it's a sensible fix 😅
But opening a PR in case it helps others!
Amp explained it like this:
Problem
Using
open_in_prev_tabwithclose_on_open_in_prev_tab = truetriggersE5108: "Problem while switching windows".
The
TabClosedautocmd runscleanup_diffsynchronously, which eventuallycalls
vim.wo[winid][name] = valueinwelcome_window.apply_opts. Settingwindow-local options requires Neovim to switch windows internally, which is
forbidden during a
TabClosedevent.Fix
Wrap the
TabClosedcallback body invim.schedule()to defer cleanupuntil after the event loop settles. This matches the pattern already used
by the
WinClosedhandler in the same file.