aboutsummaryrefslogtreecommitdiff
path: root/cmd-link-window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2008-06-05 22:59:38 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2008-06-05 22:59:38 +0000
commit197347b61f4f6cfdf0da94aa3d6205e692e5954e (patch)
treee64882c3fe2a781d76d4e4545c1fc80efbcaea3b /cmd-link-window.c
parent741f8967b40121f0364c90635bd609df9cdcd933 (diff)
downloadrtmux-197347b61f4f6cfdf0da94aa3d6205e692e5954e.tar.gz
rtmux-197347b61f4f6cfdf0da94aa3d6205e692e5954e.tar.bz2
rtmux-197347b61f4f6cfdf0da94aa3d6205e692e5954e.zip
Don't bork on link/swap the same window. Also extend comment.
Diffstat (limited to 'cmd-link-window.c')
-rw-r--r--cmd-link-window.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/cmd-link-window.c b/cmd-link-window.c
index a1c298f4..54ea5dc3 100644
--- a/cmd-link-window.c
+++ b/cmd-link-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-link-window.c,v 1.19 2008-06-05 21:25:00 nicm Exp $ */
+/* $Id: cmd-link-window.c,v 1.20 2008-06-05 22:59:38 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -66,16 +66,20 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
return;
}
- if (data->flags & CMD_KFLAG) {
+ if (idx != -1)
wl_dst = winlink_find_by_index(&s->windows, idx);
- if (wl_dst != NULL) {
+ if (wl_dst != NULL) {
+ if (wl_dst->window == wl_src->window)
+ goto out;
+
+ if (data->flags & CMD_KFLAG) {
/*
* Can't use session_detach as it will destroy session
* if this makes it empty.
*/
session_alert_cancel(s, wl_dst);
winlink_remove(&s->windows, wl_dst);
-
+
/* Force select/redraw if current. */
if (wl_dst == s->curw) {
data->flags &= ~CMD_DFLAG;
@@ -85,8 +89,8 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
s->lastw = NULL;
/*
- * Can't error out after this or there could be an empty
- * session!
+ * Can't error out after this or there could be an
+ * empty session!
*/
}
}
@@ -104,6 +108,7 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
server_redraw_session(s);
}
+out:
if (ctx->cmdclient != NULL)
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}