From 194a121ef68d5af557e3e158d1aa6a8f013cd2ac Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 21 Apr 2017 22:00:06 +0000 Subject: [PATCH] Make sure cmd_find_from_* clear the state if they fail. --- cmd-find.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/cmd-find.c b/cmd-find.c index 098405aa..edd43a8b 100644 --- a/cmd-find.c +++ b/cmd-find.c @@ -749,8 +749,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); @@ -764,10 +766,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); @@ -796,8 +802,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); @@ -811,8 +819,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; @@ -832,8 +842,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); @@ -902,6 +914,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; @@ -1083,8 +1096,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. */