aboutsummaryrefslogtreecommitdiff
path: root/cmd-find.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2015-04-29 18:42:12 +0100
committerThomas Adam <thomas@xteddy.org>2015-04-29 18:42:12 +0100
commitc0cf4843e50ae7b123613798c209f30440d73e55 (patch)
tree7e5724f11e8cbfa0a4480a6dacb04fb98ee68246 /cmd-find.c
parent8794562a85ab7221b4ec3b165723faa8ca10db0a (diff)
parent69b8f100b70061ee2520fb30368a955cf39e47db (diff)
downloadrtmux-c0cf4843e50ae7b123613798c209f30440d73e55.tar.gz
rtmux-c0cf4843e50ae7b123613798c209f30440d73e55.tar.bz2
rtmux-c0cf4843e50ae7b123613798c209f30440d73e55.zip
Merge branch 'obsd-master'
Diffstat (limited to 'cmd-find.c')
-rw-r--r--cmd-find.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/cmd-find.c b/cmd-find.c
index fab3849f..3f7ad660 100644
--- a/cmd-find.c
+++ b/cmd-find.c
@@ -242,10 +242,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) {
@@ -425,7 +428,20 @@ 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) {
+ if (~fs->flags & CMD_FIND_WINDOW_INDEX) {
+ fs->wl = fs->s->curw;
+ fs->w = fs->wl->window;
+ fs->idx = fs->wl->idx;
+ }
+ return (0);
+ }
+
+ return (-1);
}
/*
@@ -591,14 +607,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);
}
/*