diff options
author | 2014-04-17 09:13:13 +0000 | |
---|---|---|
committer | 2014-04-17 09:13:13 +0000 | |
commit | e2f09fc8cd53ff4e1843a1d7b16b6c2bc87e41fb (patch) | |
tree | 82b699bb08cc457646a2e8b68ae0de4c60c16419 | |
parent | It's been a quarter century: we can assume volatile is present with that name. (diff) | |
download | wireguard-openbsd-e2f09fc8cd53ff4e1843a1d7b16b6c2bc87e41fb.tar.xz wireguard-openbsd-e2f09fc8cd53ff4e1843a1d7b16b6c2bc87e41fb.zip |
Correct the dance to fix the active pane in join-pane by pulling the
(right) code from break-pane and window_remove_pane into a helper
function.
-rw-r--r-- | usr.bin/tmux/cmd-break-pane.c | 13 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-join-pane.c | 8 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 3 | ||||
-rw-r--r-- | usr.bin/tmux/window.c | 10 |
4 files changed, 14 insertions, 20 deletions
diff --git a/usr.bin/tmux/cmd-break-pane.c b/usr.bin/tmux/cmd-break-pane.c index 8186cb3f211..a4d63da717a 100644 --- a/usr.bin/tmux/cmd-break-pane.c +++ b/usr.bin/tmux/cmd-break-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-break-pane.c,v 1.22 2013/10/10 12:00:18 nicm Exp $ */ +/* $OpenBSD: cmd-break-pane.c,v 1.23 2014/04/17 09:13:13 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -65,16 +65,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq) server_unzoom_window(w); TAILQ_REMOVE(&w->panes, wp, entry); - if (wp == w->active) { - w->active = w->last; - w->last = NULL; - if (w->active == NULL) { - w->active = TAILQ_PREV(wp, window_panes, entry); - if (w->active == NULL) - w->active = TAILQ_NEXT(wp, entry); - } - } else if (wp == w->last) - w->last = NULL; + window_lost_pane(w, wp); layout_close_pane(wp); w = wp->window = window_create1(s->sx, s->sy); diff --git a/usr.bin/tmux/cmd-join-pane.c b/usr.bin/tmux/cmd-join-pane.c index 0948c6e975b..d75ed6884e0 100644 --- a/usr.bin/tmux/cmd-join-pane.c +++ b/usr.bin/tmux/cmd-join-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-join-pane.c,v 1.15 2013/10/10 12:00:19 nicm Exp $ */ +/* $OpenBSD: cmd-join-pane.c,v 1.16 2014/04/17 09:13:13 nicm Exp $ */ /* * Copyright (c) 2011 George Nachman <tmux@georgester.com> @@ -139,11 +139,7 @@ join_pane(struct cmd *self, struct cmd_q *cmdq, int not_same_window) layout_close_pane(src_wp); - if (src_w->active == src_wp) { - src_w->active = TAILQ_PREV(src_wp, window_panes, entry); - if (src_w->active == NULL) - src_w->active = TAILQ_NEXT(src_wp, entry); - } + window_lost_pane(src_w, src_wp); TAILQ_REMOVE(&src_w->panes, src_wp, entry); if (window_count_panes(src_w) == 0) diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 4c776082b30..2eb13043957 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.452 2014/04/17 07:55:43 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.453 2014/04/17 09:13:13 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -2138,6 +2138,7 @@ struct window_pane *window_add_pane(struct window *, u_int); void window_resize(struct window *, u_int, u_int); int window_zoom(struct window_pane *); int window_unzoom(struct window *); +void window_lost_pane(struct window *, struct window_pane *); void window_remove_pane(struct window *, struct window_pane *); struct window_pane *window_pane_at_index(struct window *, u_int); struct window_pane *window_pane_next_by_number(struct window *, diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index cf1d176fd26..e0f23c10119 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.104 2014/04/17 07:36:45 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.105 2014/04/17 09:13:13 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -591,7 +591,7 @@ window_add_pane(struct window *w, u_int hlimit) } void -window_remove_pane(struct window *w, struct window_pane *wp) +window_lost_pane(struct window *w, struct window_pane *wp) { if (wp == w->active) { w->active = w->last; @@ -603,6 +603,12 @@ window_remove_pane(struct window *w, struct window_pane *wp) } } else if (wp == w->last) w->last = NULL; +} + +void +window_remove_pane(struct window *w, struct window_pane *wp) +{ + window_lost_pane(w, wp); TAILQ_REMOVE(&w->panes, wp, entry); window_pane_destroy(wp); |