Fix restore silently skipping windows whose index is shadowed by a window name#575
Open
theolundqvist wants to merge 1 commit into
Open
Conversation
…ed index tmux resolves a "session:N" target by falling back to window-name prefix matching when window index N does not exist. During a restore that is the common case: the window being restored is gone, and any window whose auto-rename name starts with the digit N (e.g. a pane running a binary named "2_1_199") matches the target instead. pane_exists then reports the dead window's panes as existing and restore silently skips recreating them. List all panes in the session keyed by numeric window_index instead, so window names can never shadow a window index.
theolundqvist
force-pushed
the
fix-pane-exists-index-collision
branch
from
July 3, 2026 07:49
2a1bd41 to
1000d19
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.
I lost a window on every restore and it took a bash -x trace to see why.
pane_exists()targetssession:N, and when window index N does not exist (the normal case for a window being restored), tmux quietly falls back to matching window names by prefix. My windows are auto-renamed after the running command, which happens to be a versioned binary called2_1_199, so the check for dead window 2 matched that window by name, reported its panes as already existing, and restore skipped recreating the window entirely. Any window name starting with a digit can trigger this.The fix lists all panes in the session keyed by
#{window_index}and matches the index exactly, so names can never shadow indices. Behavior is unchanged when the window actually exists.Repro:
tmux rename-window 2_1_199on window 1, create window 2 with any pane, save, kill window 2, restore. Window 2 never comes back.