Skip to content

Fix restore silently skipping windows whose index is shadowed by a window name#575

Open
theolundqvist wants to merge 1 commit into
tmux-plugins:masterfrom
theolundqvist:fix-pane-exists-index-collision
Open

Fix restore silently skipping windows whose index is shadowed by a window name#575
theolundqvist wants to merge 1 commit into
tmux-plugins:masterfrom
theolundqvist:fix-pane-exists-index-collision

Conversation

@theolundqvist

@theolundqvist theolundqvist commented Jul 3, 2026

Copy link
Copy Markdown

I lost a window on every restore and it took a bash -x trace to see why. pane_exists() targets session: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 called 2_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_199 on window 1, create window 2 with any pane, save, kill window 2, restore. Window 2 never comes back.

slide-01.png
slide-02.png

…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
theolundqvist force-pushed the fix-pane-exists-index-collision branch from 2a1bd41 to 1000d19 Compare July 3, 2026 07:49
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