Commit d2f6ca0
committed
fix(tools): Anchor select_pane direction=next/previous to the targeted window
why: window.cmd("select-pane", "-t", "+1") assembles to
`tmux select-pane -t @window_id -t +1`. tmux's args_get() returns
the LAST -t value (arguments.c:675-683), so the effective target
is the bare `+1`. Bare relative pane targets resolve against
`fs->current = c->session->curw` — the ATTACHED CLIENT's currently
focused window (cmd-find.c:876-878, 513-517, 612-623), not any
earlier -t on the command line.
Practical effect: calling select_pane(direction="next",
window_id=w2) while the client has w1 focused shifts the active
pane in w1 and leaves w2 untouched. Reproduced on a scratch tmux
server. This is the same class of bug that commit 8a8d7c6 fixed
for select_window directional navigation, which I previously
dismissed on select_pane based on a single-window probe that
couldn't expose the misrouting.
The fix uses the window-scoped relative pane spec
`@window_id.+` / `@window_id.-`. The target-parser at
cmd-find.c:1049-1097 splits on `.`, resolves the window part via
window_find_by_id_str (cmd-find.c:317-321), and applies the
offset against that explicit window's active pane
(cmd-find.c:612-623 with fs->w already bound to the named window
rather than s->curw). Routed through server.cmd(..., target=...)
to bypass Window.cmd's auto-target injection that would otherwise
reintroduce the duplicate-`-t` situation.
what:
- Switch the "next" and "previous" branches in select_pane from
`window.cmd("select-pane", "-t", "+1"/"-1")` to
`server.cmd("select-pane", target=f"{window.window_id}.+"/".-")`.
- Add test_select_pane_next_previous_respects_target_window: a
multi-window fixture where w1 is the active window and w2 is
not. The test calls select_pane(direction="next", window_id=w2)
and asserts (a) w2's active pane changed, (b) w1's active pane
did NOT change, and (c) the returned PaneInfo describes a pane
in w2. Verified to FAIL against the previous code and PASS with
the fix.
- No change to the "up/down/left/right/last" branches — those
route through window.select_pane(flag), which uses the non-
relative `-U/-D/-L/-R/-l` flags and is not affected by
relative-target resolution.1 parent 83e6105 commit d2f6ca0
2 files changed
Lines changed: 66 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
870 | 870 | | |
871 | 871 | | |
872 | 872 | | |
873 | | - | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
874 | 879 | | |
875 | | - | |
| 880 | + | |
876 | 881 | | |
877 | 882 | | |
878 | 883 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
696 | 696 | | |
697 | 697 | | |
698 | 698 | | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
699 | 758 | | |
700 | 759 | | |
701 | 760 | | |
| |||
0 commit comments