summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-find.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2015-12-13 17:55:14 +0000
committernicm <nicm@openbsd.org>2015-12-13 17:55:14 +0000
commit59d5062af89e99bf5093518c7d115453de93c13c (patch)
tree6859f29d8cca8bf4815961046a9734a4384090cb /usr.bin/tmux/cmd-find.c
parentChange cmd_find_target to use a state struct from the caller. (diff)
downloadwireguard-openbsd-59d5062af89e99bf5093518c7d115453de93c13c.tar.xz
wireguard-openbsd-59d5062af89e99bf5093518c7d115453de93c13c.zip
Use struct cmd_find_state directly and remove cmd_state_flag, also
change so that winlink is set even if an index is too.
Diffstat (limited to 'usr.bin/tmux/cmd-find.c')
-rw-r--r--usr.bin/tmux/cmd-find.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/usr.bin/tmux/cmd-find.c b/usr.bin/tmux/cmd-find.c
index f7d7a3a42f4..cc1891eca68 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.20 2015/12/13 16:44:35 nicm Exp $ */
+/* $OpenBSD: cmd-find.c,v 1.21 2015/12/13 17:55:14 nicm Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -467,11 +467,10 @@ cmd_find_get_window(struct cmd_find_state *fs, const char *window)
/* Otherwise try as a session itself. */
if (cmd_find_get_session(fs, window) == 0) {
- if (~fs->flags & CMD_FIND_WINDOW_INDEX) {
- fs->wl = fs->s->curw;
- fs->w = fs->wl->window;
+ fs->wl = fs->s->curw;
+ fs->w = fs->wl->window;
+ if (~fs->flags & CMD_FIND_WINDOW_INDEX)
fs->idx = fs->wl->idx;
- }
return (0);
}
@@ -493,6 +492,13 @@ cmd_find_get_window_with_session(struct cmd_find_state *fs, const char *window)
log_debug("%s: %s", __func__, window);
exact = (fs->flags & CMD_FIND_EXACT_WINDOW);
+ /*
+ * Start with the current window as the default. So if only an index is
+ * found, the window will be the current.
+ */
+ fs->wl = fs->s->curw;
+ fs->w = fs->wl->window;
+
/* Check for window ids starting with @. */
if (*window == '@') {
fs->w = window_find_by_id_str(window);
@@ -976,8 +982,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_q *cmdq,
/* This will fill in winlink and window. */
if (cmd_find_get_window_with_session(fs, window) != 0)
goto no_window;
- if (~flags & CMD_FIND_WINDOW_INDEX)
- fs->wp = fs->wl->window->active;
+ fs->wp = fs->wl->window->active;
goto found;
}
@@ -1017,8 +1022,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_q *cmdq,
/* This will fill in session, winlink and window. */
if (cmd_find_get_window(fs, window) != 0)
goto no_window;
- if (~flags & CMD_FIND_WINDOW_INDEX)
- fs->wp = fs->wl->window->active;
+ fs->wp = fs->wl->window->active;
goto found;
}