From 094a047ddfe43817ac7f670668fd7d648349f6cd Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 28 Apr 2015 11:33:17 +0000 Subject: If can't find pane as a pane, try as a window; likewise if can't find window as a session. --- cmd-find.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'cmd-find.c') diff --git a/cmd-find.c b/cmd-find.c index f7c1ba74..e937b6dc 100644 --- a/cmd-find.c +++ b/cmd-find.c @@ -426,7 +426,18 @@ cmd_find_get_window(struct cmd_find_state *fs, const char *window) fs->s = fs->current->s; /* We now only need to find the winlink in this session. */ - return (cmd_find_get_window_with_session(fs, window)); + if (cmd_find_get_window_with_session(fs, window) == 0) + return (0); + + /* Otherwise try as a session itself. */ + if (cmd_find_get_session(fs, window) == 0) { + fs->wl = fs->s->curw; + fs->idx = fs->wl->idx; + fs->w = fs->wl->window; + return (0); + } + + return (-1); } /* @@ -592,14 +603,23 @@ cmd_find_get_pane(struct cmd_find_state *fs, const char *pane) return (cmd_find_best_session_with_window(fs)); } - /* Not a pane id, so use the current session and window. */ + /* Not a pane id, so try the current session and window. */ fs->s = fs->current->s; fs->wl = fs->current->wl; fs->idx = fs->current->idx; fs->w = fs->current->w; /* We now only need to find the pane in this window. */ - return (cmd_find_get_pane_with_window(fs, pane)); + if (cmd_find_get_pane_with_window(fs, pane) == 0) + return (0); + + /* Otherwise try as a window itself (this will also try as session). */ + if (cmd_find_get_window(fs, pane) == 0) { + fs->wp = fs->w->active; + return (0); + } + + return (-1); } /* -- cgit From 14d8cd64455e34c1c3f5803210e1162d4a03fb48 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 28 Apr 2015 11:57:20 +0000 Subject: Do not do a search for the tty path if there isn't one. --- cmd-find.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'cmd-find.c') diff --git a/cmd-find.c b/cmd-find.c index e937b6dc..e9d80cbe 100644 --- a/cmd-find.c +++ b/cmd-find.c @@ -243,10 +243,13 @@ cmd_find_current_session_with_client(struct cmd_find_state *fs) struct window_pane *wp; /* If this is running in a pane, that's great. */ - RB_FOREACH(wp, window_pane_tree, &all_window_panes) { - if (strcmp(wp->tty, fs->cmdq->client->tty.path) == 0) - break; - } + if (fs->cmdq->client->tty.path != NULL) { + RB_FOREACH(wp, window_pane_tree, &all_window_panes) { + if (strcmp(wp->tty, fs->cmdq->client->tty.path) == 0) + break; + } + } else + wp = NULL; /* Not running in a pane. We know nothing. Find the best session. */ if (wp == NULL) { -- cgit From e36fab2f7093e018de51af35e2c37b7a11201c2e Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 28 Apr 2015 12:09:24 +0000 Subject: If looking for an index, don't fill in window when given a session. --- cmd-find.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'cmd-find.c') diff --git a/cmd-find.c b/cmd-find.c index e9d80cbe..ec4cf6c1 100644 --- a/cmd-find.c +++ b/cmd-find.c @@ -434,9 +434,11 @@ 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) { - fs->wl = fs->s->curw; - fs->idx = fs->wl->idx; - fs->w = fs->wl->window; + if (~fs->flags & CMD_FIND_WINDOW_INDEX) { + fs->wl = fs->s->curw; + fs->w = fs->wl->window; + fs->idx = fs->wl->idx; + } return (0); } -- cgit