Repository navigation
fix(stack): Make popup close, visibility and restore lifecycle consistent - #53
Merged
Merged
Conversation
close_all closed each window while its popup was still in the stack, so the WinClosed autocmd reported the popup a second time and three popups produced six PeekstackClose events. A quick peek closed from outside dropped its model without releasing it, leaving diagnostic extmarks in the source buffer. Every close route now detaches the model first, then releases decorations and keymaps, closes the window, and records the close and history entry once; an externally closed popup can now be restored with undo close as well.
Closing a popup wipes its copy buffer, and the periodic cleanup treated that as a lost origin and closed every popup opened from it, even pinned ones or ones with unsaved source edits. The BufWipeout handler already kept such children. Both now share one rule: only popups opened from a regular buffer close together with it.
The test init points XDG_STATE_HOME at .tmp/state, so every test run left an untracked .tmp/ directory in the working tree.
Restoring from history or focusing a popup while the stack was hidden opened a window without showing the stack, and the next toggle opened every popup again, leaving the earlier window as an untracked float that close-all could not reach. These operations and push now show the stack first through one path, which reopens only popups without a live window; reopen_by_id also returns a popup that is already shown as is.
restore_all reopened entries newest first and resolved each parent on the spot, so a parent closed before its child was not open yet and the child lost its parent. Popups are now opened first and their parents linked in a second pass through the ids they were restored under, and the push events follow once the tree is complete. Single restores keep using the same id mapping.
Cursor tracking was attached to a popup buffer on WinEnter, but the first WinEnter fires while the window is opened, before the popup is registered. A popup that was never left and re-entered kept its creation time as last activity and was auto-closed while in use. The CursorMoved hook is now global and touches whichever popup window the cursor moves in.
After :buffer or :edit inside a popup, the popup still described the previous buffer, so provider requests used the new cursor position in the old file and the stack view, title and history kept the old place. For copy popups the wiped copy buffer even dropped the popup and left its window as an untracked float. The popup now follows the new buffer as a source-mode popup at the cursor, moving its keymaps, title and location along and releasing what it placed on the old buffer.
Document that undo close also covers popups closed outside peekstack, that restore-all keeps parent links, that focusing or restoring a popup shows a hidden stack, and that a popup follows a buffer switched into its window.
mhiro2
force-pushed
the
fix/popup-lifecycle
branch
from
October 3, 2026 13:26
ed41313 to
f9efaa9
Compare
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.
Summary
:buffer/:editinside its window as a source popup at the final cursor positionChanges
:q/<C-w>ccan be restored with undo close.tmp/in the working tree:edit +N, last position) is captured after the command, or at close if that comes first