summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2017-04-21 22:00:07 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2017-04-21 22:00:07 +0000
commit7d34bef33bb59a4224faa192266a7583ce2af0d4 (patch)
tree94ae660b7eb825d4fde8140475e50d0cc3d3af6e /usr.bin
parent5fbbb1054fe82c573714dee58e18fc892fa267bb (diff)
Make sure cmd_find_from_* clear the state if they fail.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/cmd-find.c31
1 files 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 <nicholas.marriott@gmail.com>
@@ -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. */