summaryrefslogtreecommitdiffstats
path: root/cmd-new-window.c
diff options
context:
space:
mode:
authornicm <nicm>2013-11-23 09:18:29 +0000
committernicm <nicm>2013-11-23 09:18:29 +0000
commit40982a01fb39b7be749bc807a06ba352dd6c2e5e (patch)
tree3032be741ce5a68f0f3e5af5d7c01b72b102947c /cmd-new-window.c
parent7aeb4473add76e11dd595919f81ff5d9cad28718 (diff)
With -k, kill window after using it to work out -c path. Reported by
jmacristovao at gmail dot com.
Diffstat (limited to 'cmd-new-window.c')
-rw-r--r--cmd-new-window.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/cmd-new-window.c b/cmd-new-window.c
index 354d0ae5..e205e6bc 100644
--- a/cmd-new-window.c
+++ b/cmd-new-window.c
@@ -82,26 +82,6 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
}
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
@@ -133,6 +113,26 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
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");
wl = session_new(s, args_get(args, 'n'), cmd, cwd, idx, &cause);