From 9a5690fe11bbbaa13f3844a92b0f47dca8b24d3d 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. --- usr.bin/tmux/cmd-find.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/usr.bin/tmux/cmd-find.c b/usr.bin/tmux/cmd-find.c index 7f443f594e2..b1603bddec2 100644 --- a/usr.bin/tmux/cmd-find.c +++ b/usr.bin/tmux/cmd-find.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-find.c,v 1.48 2017/04/21 20:26:34 nicm Exp $ */ +/* $OpenBSD: cmd-find.c,v 1.49 2017/04/21 22:00:06 nicm Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott @@ -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. */ -- 2.20.1