From 197347b61f4f6cfdf0da94aa3d6205e692e5954e Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 5 Jun 2008 22:59:38 +0000 Subject: Don't bork on link/swap the same window. Also extend comment. --- cmd-link-window.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'cmd-link-window.c') 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 @@ -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); } -- cgit