diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2016-12-14 17:39:00 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2016-12-14 17:39:00 +0000 |
commit | 893bb9f4db481d9c3e20a57f97522e73100637d3 (patch) | |
tree | 46f10ee56bfb0c8640291ba64653246f84c1a039 /usr.bin | |
parent | 11e54de2dfe1068c371cccc2980a73f26e7ad9c9 (diff) |
Fix up winlink lists after swap-window.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/cmd-swap-window.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.bin/tmux/cmd-swap-window.c b/usr.bin/tmux/cmd-swap-window.c index cf6ee4ca3a4..5172028efce 100644 --- a/usr.bin/tmux/cmd-swap-window.c +++ b/usr.bin/tmux/cmd-swap-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-swap-window.c,v 1.20 2016/10/16 19:04:05 nicm Exp $ */ +/* $OpenBSD: cmd-swap-window.c,v 1.21 2016/12/14 17:38:59 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -48,7 +48,7 @@ cmd_swap_window_exec(struct cmd *self, struct cmdq_item *item) struct session *src, *dst; struct session_group *sg_src, *sg_dst; struct winlink *wl_src, *wl_dst; - struct window *w; + struct window *w_src, *w_dst; wl_src = item->state.sflag.wl; src = item->state.sflag.s; @@ -67,9 +67,15 @@ cmd_swap_window_exec(struct cmd *self, struct cmdq_item *item) if (wl_dst->window == wl_src->window) return (CMD_RETURN_NORMAL); - w = wl_dst->window; - wl_dst->window = wl_src->window; - wl_src->window = w; + w_dst = wl_dst->window; + TAILQ_REMOVE(&w_dst->winlinks, wl_dst, wentry); + w_src = wl_src->window; + TAILQ_REMOVE(&w_src->winlinks, wl_src, wentry); + + wl_dst->window = w_src; + TAILQ_INSERT_TAIL(&w_src->winlinks, wl_dst, wentry); + wl_src->window = w_dst; + TAILQ_INSERT_TAIL(&w_dst->winlinks, wl_src, wentry); if (!args_has(self->args, 'd')) { session_select(dst, wl_dst->idx); |