[PATCH] cmd-join-pane: teach pane's before-ness internally

16 views
Skip to first unread message

Takeshi Banse

unread,
Jan 6, 2021, 12:52:14 AM1/6/21
to tmux-...@googlegroups.com
Signed-off-by: Takeshi Banse <t...@laafc.net>
---
Hi,

I've found that the `join-pane -b` command does not preserve the pane's
berofe-ness internally.

For example:
The commands `join-pane -b` then `select-layout even-horizontal` are issued,
the newly joined pane swaps its position from above.

Below is an example shell session:
----
% ./tmux -f/dev/null -S/tmp/join-b.sock new
% cat >/tmp/tmux-run-join-b<<'EOT'
split-window -I # The *new* pane which has contents from stdin created
break-pane
select-pane -m
select-window -t!
join-pane -b -t. # at the first site, `join-pane -b` works as expected, but
select-layout even-vertical
# but the *new* pane swaps its position at this point
EOT
% echo new-above | \
./tmux -f/dev/null -S/tmp/join-b.sock source /tmp/tmux-run-join-b
----

I expect that the newly created pane (the "new-above" pane) stays on above
after the command `select-layout even-vertical`. But the "new-obove" pane
does not stay on top in this case.

Below patch teaches the same thing in layout.c:layout_split_pane().

cmd-join-pane.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/cmd-join-pane.c b/cmd-join-pane.c
index 306cf4bc..36805c46 100644
--- a/cmd-join-pane.c
+++ b/cmd-join-pane.c
@@ -142,7 +142,10 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
src_wp->window = dst_w;
options_set_parent(src_wp->options, dst_w->options);
src_wp->flags |= PANE_STYLECHANGED;
- TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry);
+ if (flags & SPAWN_BEFORE)
+ TAILQ_INSERT_BEFORE(dst_wp, src_wp, entry);
+ else
+ TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry);
layout_assign_pane(lc, src_wp);

recalculate_sizes();
--
2.30.0

Nicholas Marriott

unread,
Jan 6, 2021, 6:28:40 AM1/6/21
to Takeshi Banse, tmux-...@googlegroups.com

Nice one, applied now, thanks!
> --
> You received this message because you are subscribed to the Google Groups "tmux-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to tmux-users+...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/tmux-users/20210106055210.755-1-thb%40laafc.net.
Reply all
Reply to author
Forward
0 new messages