Thomas Adam
2015-04-21 15:28:38 UTC
Rather than blindly call session_renumber_session when the option wasn't
requested (and hence breaking the case of renumbering a winlink manually),
instead only renumber the src session, since that session is the one which
will have "gaps".
---
cmd-move-window.c | 12 +++++++++++-
server-fn.c | 1 -
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/cmd-move-window.c b/cmd-move-window.c
index 3064cd6..8db4534 100644
--- a/cmd-move-window.c
+++ b/cmd-move-window.c
@@ -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 use; either
+ * automatically or specified by -s in this command.
+ */
+ if (!sflag && options_get_number(&src->options, "renumber-windows"))
+ session_renumber_windows(src);
+
recalculate_sizes();
return (CMD_RETURN_NORMAL);
diff --git a/server-fn.c b/server-fn.c
index b35eace..f2b2e26 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -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
requested (and hence breaking the case of renumbering a winlink manually),
instead only renumber the src session, since that session is the one which
will have "gaps".
---
cmd-move-window.c | 12 +++++++++++-
server-fn.c | 1 -
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/cmd-move-window.c b/cmd-move-window.c
index 3064cd6..8db4534 100644
--- a/cmd-move-window.c
+++ b/cmd-move-window.c
@@ -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 use; either
+ * automatically or specified by -s in this command.
+ */
+ if (!sflag && options_get_number(&src->options, "renumber-windows"))
+ session_renumber_windows(src);
+
recalculate_sizes();
return (CMD_RETURN_NORMAL);
diff --git a/server-fn.c b/server-fn.c
index b35eace..f2b2e26 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -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
--
2.1.4
2.1.4