aboutsummaryrefslogtreecommitdiff
path: root/cmd-find.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd-find.c')
-rw-r--r--cmd-find.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/cmd-find.c b/cmd-find.c
index 30c433b6..4c08147d 100644
--- a/cmd-find.c
+++ b/cmd-find.c
@@ -466,11 +466,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);
}
@@ -492,6 +491,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);
@@ -975,8 +981,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;
}
@@ -1016,8 +1021,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;
}