=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-new-window.c,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- src/usr.bin/tmux/cmd-new-window.c 2013/11/22 20:58:36 1.37 +++ src/usr.bin/tmux/cmd-new-window.c 2013/11/23 09:18:29 1.38 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-window.c,v 1.37 2013/11/22 20:58:36 nicm Exp $ */ +/* $OpenBSD: cmd-new-window.c,v 1.38 2013/11/23 09:18:29 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -82,26 +82,6 @@ } detached = args_has(args, 'd'); - wl = NULL; - if (idx != -1) - wl = winlink_find_by_index(&s->windows, idx); - if (wl != NULL && args_has(args, 'k')) { - /* - * Can't use session_detach as it will destroy session if this - * makes it empty. - */ - notify_window_unlinked(s, wl->window); - wl->flags &= ~WINLINK_ALERTFLAGS; - winlink_stack_remove(&s->lastw, wl); - winlink_remove(&s->windows, wl); - - /* Force select/redraw if current. */ - if (wl == s->curw) { - detached = 0; - s->curw = NULL; - } - } - if (args->argc == 0) cmd = options_get_string(&s->options, "default-command"); else @@ -132,6 +112,26 @@ cwd = cmdq->client->cwd; else cwd = s->cwd; + + wl = NULL; + if (idx != -1) + wl = winlink_find_by_index(&s->windows, idx); + if (wl != NULL && args_has(args, 'k')) { + /* + * Can't use session_detach as it will destroy session if this + * makes it empty. + */ + notify_window_unlinked(s, wl->window); + wl->flags &= ~WINLINK_ALERTFLAGS; + winlink_stack_remove(&s->lastw, wl); + winlink_remove(&s->windows, wl); + + /* Force select/redraw if current. */ + if (wl == s->curw) { + detached = 0; + s->curw = NULL; + } + } if (idx == -1) idx = -1 - options_get_number(&s->options, "base-index");