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.
This commit is contained in:
nicm 2014-04-17 09:13:13 +00:00
parent 2740490e27
commit 2e98c9057d
4 changed files with 10 additions and 16 deletions

View File

@ -65,16 +65,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
server_unzoom_window(w); server_unzoom_window(w);
TAILQ_REMOVE(&w->panes, wp, entry); TAILQ_REMOVE(&w->panes, wp, entry);
if (wp == w->active) { window_lost_pane(w, wp);
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;
layout_close_pane(wp); layout_close_pane(wp);
w = wp->window = window_create1(s->sx, s->sy); w = wp->window = window_create1(s->sx, s->sy);

View File

@ -139,11 +139,7 @@ join_pane(struct cmd *self, struct cmd_q *cmdq, int not_same_window)
layout_close_pane(src_wp); layout_close_pane(src_wp);
if (src_w->active == src_wp) { window_lost_pane(src_w, 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);
}
TAILQ_REMOVE(&src_w->panes, src_wp, entry); TAILQ_REMOVE(&src_w->panes, src_wp, entry);
if (window_count_panes(src_w) == 0) if (window_count_panes(src_w) == 0)

1
tmux.h
View File

@ -2138,6 +2138,7 @@ struct window_pane *window_add_pane(struct window *, u_int);
void window_resize(struct window *, u_int, u_int); void window_resize(struct window *, u_int, u_int);
int window_zoom(struct window_pane *); int window_zoom(struct window_pane *);
int window_unzoom(struct window *); int window_unzoom(struct window *);
void window_lost_pane(struct window *, struct window_pane *);
void window_remove_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_at_index(struct window *, u_int);
struct window_pane *window_pane_next_by_number(struct window *, struct window_pane *window_pane_next_by_number(struct window *,

View File

@ -591,7 +591,7 @@ window_add_pane(struct window *w, u_int hlimit)
} }
void 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) { if (wp == w->active) {
w->active = w->last; w->active = w->last;
@ -603,6 +603,12 @@ window_remove_pane(struct window *w, struct window_pane *wp)
} }
} else if (wp == w->last) } else if (wp == w->last)
w->last = NULL; 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); TAILQ_REMOVE(&w->panes, wp, entry);
window_pane_destroy(wp); window_pane_destroy(wp);