diff --git a/cmd-find.c b/cmd-find.c index ecad994e..12de97e1 100644 --- a/cmd-find.c +++ b/cmd-find.c @@ -748,8 +748,10 @@ cmd_find_from_session_window(struct cmd_find_state *fs, struct session *s, fs->s = s; fs->w = w; - if (cmd_find_best_winlink_with_window(fs) != 0) + if (cmd_find_best_winlink_with_window(fs) != 0) { + cmd_find_clear_state(fs, 0); return (-1); + } fs->wp = fs->w->active; cmd_find_log_state(__func__, fs); @@ -763,10 +765,14 @@ cmd_find_from_window(struct cmd_find_state *fs, struct window *w) cmd_find_clear_state(fs, 0); fs->w = w; - if (cmd_find_best_session_with_window(fs) != 0) + if (cmd_find_best_session_with_window(fs) != 0) { + cmd_find_clear_state(fs, 0); return (-1); - if (cmd_find_best_winlink_with_window(fs) != 0) + } + if (cmd_find_best_winlink_with_window(fs) != 0) { + cmd_find_clear_state(fs, 0); return (-1); + } fs->wp = fs->w->active; cmd_find_log_state(__func__, fs); @@ -795,8 +801,10 @@ cmd_find_from_pane(struct cmd_find_state *fs, struct window_pane *wp) { if (cmd_find_from_window(fs, wp->window) != 0) return (-1); - if (window_pane_outside(wp)) + if (window_pane_outside(wp)) { + cmd_find_clear_state(fs, 0); return (-1); + } fs->wp = wp; cmd_find_log_state(__func__, fs); @@ -810,8 +818,10 @@ cmd_find_from_nothing(struct cmd_find_state *fs) cmd_find_clear_state(fs, 0); fs->s = cmd_find_best_session(NULL, 0, fs->flags); - if (fs->s == NULL) + if (fs->s == NULL) { + cmd_find_clear_state(fs, 0); return (-1); + } fs->wl = fs->s->curw; fs->idx = fs->wl->idx; fs->w = fs->wl->window; @@ -831,8 +841,10 @@ cmd_find_from_mouse(struct cmd_find_state *fs, struct mouse_event *m) return (-1); fs->wp = cmd_mouse_pane(m, &fs->s, &fs->wl); - if (fs->wp == NULL) + if (fs->wp == NULL) { + cmd_find_clear_state(fs, 0); return (-1); + } fs->w = fs->wl->window; cmd_find_log_state(__func__, fs); @@ -901,6 +913,7 @@ cmd_find_from_client(struct cmd_find_state *fs, struct client *c) */ goto unknown_pane; } + cmd_find_clear_state(fs, 0); return (-1); } fs->wl = fs->s->curw; @@ -960,9 +973,8 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item, fs->current = ¤t; log_debug("%s: current is from client", __func__); } else - return (-1); - if (!cmd_find_empty_state(fs->current) && - !cmd_find_valid_state(fs->current)) + goto error; + if (!cmd_find_valid_state(fs->current)) fatalx("invalid current find state"); /* An empty or NULL target is the current. */ @@ -1082,8 +1094,8 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item, if (pane != NULL) pane = cmd_find_map_table(cmd_find_pane_table, pane); - log_debug("target %s (flags %#x): session=%s, window=%s, pane=%s", - target, flags, session == NULL ? "none" : session, + log_debug("%s: target %s (flags %#x): session=%s, window=%s, pane=%s", + __func__, target, flags, session == NULL ? "none" : session, window == NULL ? "none" : window, pane == NULL ? "none" : pane); /* No pane is allowed if want an index. */ diff --git a/cmd-queue.c b/cmd-queue.c index a7a29b58..99ec6055 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -203,14 +203,14 @@ cmdq_fire_command(struct cmdq_item *item) flags = !!(cmd->flags & CMD_CONTROL); cmdq_guard(item, "begin", flags); + if (item->client == NULL) + item->client = cmd_find_client(item, NULL, 1); + if (cmd_prepare_state(cmd, item) != 0) { retval = CMD_RETURN_ERROR; goto out; } - if (item->client == NULL) - item->client = cmd_find_client(item, NULL, 1); - retval = cmd->entry->exec(cmd, item); if (retval == CMD_RETURN_ERROR) goto out; diff --git a/cmd-select-pane.c b/cmd-select-pane.c index 6ef83473..7fc5d6ee 100644 --- a/cmd-select-pane.c +++ b/cmd-select-pane.c @@ -63,24 +63,24 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item) const char *style; if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) { - if (wl->window->last == NULL) { + lastwp = w->last; + if (lastwp == NULL) { cmdq_error(item, "no last pane"); return (CMD_RETURN_ERROR); } if (args_has(self->args, 'e')) - w->last->flags &= ~PANE_INPUTOFF; + lastwp->flags &= ~PANE_INPUTOFF; else if (args_has(self->args, 'd')) - w->last->flags |= PANE_INPUTOFF; + lastwp->flags |= PANE_INPUTOFF; else { server_unzoom_window(w); - window_redraw_active_switch(w, w->last); - if (window_set_active_pane(w, w->last)) { + window_redraw_active_switch(w, lastwp); + if (window_set_active_pane(w, lastwp)) { server_status_window(w); server_redraw_window_borders(w); } } - return (CMD_RETURN_NORMAL); } diff --git a/server-client.c b/server-client.c index 9e99c210..ef5453bf 100644 --- a/server-client.c +++ b/server-client.c @@ -948,9 +948,6 @@ retry: if (KEYC_IS_MOUSE(key) && m->valid && wp != NULL) { cmd_find_from_winlink_pane(&fs, s->curw, wp); cmd_find_log_state(__func__, &fs); - - if (!cmd_find_valid_state(&fs)) - fatalx("invalid key state"); key_bindings_dispatch(bd, c, m, &fs); } else key_bindings_dispatch(bd, c, m, NULL);