summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-04-21 21:24:50 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-04-21 21:24:50 +0000
commitd2687c1a05f3a12873899459a643a15e0e511641 (patch)
tree79c2c2afa73012618de0d661ee3dd992e5711479 /usr.bin/tmux
parent14d21f6d32edbb3daf878a228681d7b7124bdd9f (diff)
Fix moving windows to nonexistent indexes when renumber-windows is
off. From Thomas Adam, reported by Daniel Levai and Theo Buehler.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/cmd-move-window.c14
-rw-r--r--usr.bin/tmux/server-fn.c3
2 files changed, 13 insertions, 4 deletions
diff --git a/usr.bin/tmux/cmd-move-window.c b/usr.bin/tmux/cmd-move-window.c
index c453f5abe6c..dd80a64838e 100644
--- a/usr.bin/tmux/cmd-move-window.c
+++ b/usr.bin/tmux/cmd-move-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-move-window.c,v 1.18 2014/10/27 22:40:29 nicm Exp $ */
+/* $OpenBSD: cmd-move-window.c,v 1.19 2015/04/21 21:24:49 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -51,7 +51,7 @@ cmd_move_window_exec(struct cmd *self, struct cmd_q *cmdq)
struct session *src, *dst, *s;
struct winlink *wl;
char *cause;
- int idx, kflag, dflag;
+ int idx, kflag, dflag, sflag;
if (args_has(args, 'r')) {
s = cmd_find_session(cmdq, args_get(args, 't'), 0);
@@ -71,6 +71,7 @@ cmd_move_window_exec(struct cmd *self, struct cmd_q *cmdq)
kflag = args_has(self->args, 'k');
dflag = args_has(self->args, 'd');
+ sflag = args_has(self->args, 's');
if (server_link_window(src, wl, dst, idx, kflag, !dflag,
&cause) != 0) {
cmdq_error(cmdq, "can't link window: %s", cause);
@@ -79,6 +80,15 @@ cmd_move_window_exec(struct cmd *self, struct cmd_q *cmdq)
}
if (self->entry == &cmd_move_window_entry)
server_unlink_window(src, wl);
+
+ /*
+ * Renumber the winlinks in the src session only, the destination
+ * session already has the correct winlink id to us, either
+ * automatically or specified by -s.
+ */
+ if (!sflag && options_get_number(&src->options, "renumber-windows"))
+ session_renumber_windows(src);
+
recalculate_sizes();
return (CMD_RETURN_NORMAL);
diff --git a/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c
index 6d8e417184f..808e5f35838 100644
--- a/usr.bin/tmux/server-fn.c
+++ b/usr.bin/tmux/server-fn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-fn.c,v 1.81 2015/04/19 21:46:52 nicm Exp $ */
+/* $OpenBSD: server-fn.c,v 1.82 2015/04/21 21:24:49 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -351,7 +351,6 @@ server_unlink_window(struct session *s, struct winlink *wl)
server_destroy_session_group(s);
else
server_redraw_session_group(s);
- session_renumber_windows(s);
}
void