summaryrefslogtreecommitdiffstats
path: root/cmd-find.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2020-04-09 16:01:45 +0100
committerThomas Adam <thomas@xteddy.org>2020-04-09 16:01:45 +0100
commit52e3d960e7ebe2006509d48c427ffd8f25a0cf52 (patch)
tree8f6deb3d44616e92ff05735b4c587dfe3c5d8235 /cmd-find.c
parent916c3787d7464f66287f83814d563ff36ff3a96a (diff)
parent26f5dfbe46c75f8b907ee75daaadde9a310d8dfb (diff)
Merge branch 'obsd-master'
Diffstat (limited to 'cmd-find.c')
-rw-r--r--cmd-find.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/cmd-find.c b/cmd-find.c
index 154842ab..aa36bc35 100644
--- a/cmd-find.c
+++ b/cmd-find.c
@@ -1230,29 +1230,31 @@ no_pane:
static struct client *
cmd_find_current_client(struct cmdq_item *item, int quiet)
{
- struct client *c;
+ struct client *c = NULL, *found;
struct session *s;
struct window_pane *wp;
struct cmd_find_state fs;
- if (item->client != NULL && item->client->session != NULL)
- return (item->client);
+ if (item != NULL)
+ c = item->client;
+ if (c != NULL && c->session != NULL)
+ return (c);
- c = NULL;
- if ((wp = cmd_find_inside_pane(item->client)) != NULL) {
+ found = NULL;
+ if (c != NULL && (wp = cmd_find_inside_pane(c)) != NULL) {
cmd_find_clear_state(&fs, CMD_FIND_QUIET);
fs.w = wp->window;
if (cmd_find_best_session_with_window(&fs) == 0)
- c = cmd_find_best_client(fs.s);
+ found = cmd_find_best_client(fs.s);
} else {
s = cmd_find_best_session(NULL, 0, CMD_FIND_QUIET);
if (s != NULL)
- c = cmd_find_best_client(s);
+ found = cmd_find_best_client(s);
}
- if (c == NULL && !quiet)
+ if (found == NULL && item != NULL && !quiet)
cmdq_error(item, "no current client");
- log_debug("%s: no target, return %p", __func__, c);
- return (c);
+ log_debug("%s: no target, return %p", __func__, found);
+ return (found);
}
/* Find the target client or report an error and return NULL. */