From: nicm Date: Wed, 5 Apr 2017 11:04:48 +0000 (+0000) Subject: Try again to resolve problems with mistaking sessions for windows: now X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=10f437f1930171a77be0ab305bcae8f7cc16bdfa;p=openbsd Try again to resolve problems with mistaking sessions for windows: now do not look up windows as sessions (and panes as windows) when they are qualified with a ':' or a '.'. So 'foo' as a window target will look for windows and sessions called 'foo', but ':foo' will only look for windows, and 'foo:' only for sessions. This means the common case of using an unadorned session as a window target (send -tfoo) should continue to work, but an explicit window will not get confused with a session (send -t:foo). --- diff --git a/usr.bin/tmux/cmd-find.c b/usr.bin/tmux/cmd-find.c index 5842611551f..7fb3438861b 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.43 2017/04/05 10:49:46 nicm Exp $ */ +/* $OpenBSD: cmd-find.c,v 1.44 2017/04/05 11:04:48 nicm Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott @@ -43,10 +43,10 @@ static struct client *cmd_find_current_client(struct cmdq_item *); static const char *cmd_find_map_table(const char *[][2], const char *); static int cmd_find_get_session(struct cmd_find_state *, const char *); -static int cmd_find_get_window(struct cmd_find_state *, const char *); +static int cmd_find_get_window(struct cmd_find_state *, const char *, int); static int cmd_find_get_window_with_session(struct cmd_find_state *, const char *); -static int cmd_find_get_pane(struct cmd_find_state *, const char *); +static int cmd_find_get_pane(struct cmd_find_state *, const char *, int); static int cmd_find_get_pane_with_session(struct cmd_find_state *, const char *); static int cmd_find_get_pane_with_window(struct cmd_find_state *, @@ -464,7 +464,7 @@ cmd_find_get_session(struct cmd_find_state *fs, const char *session) /* Find window from string. Fills in s, wl, w. */ static int -cmd_find_get_window(struct cmd_find_state *fs, const char *window) +cmd_find_get_window(struct cmd_find_state *fs, const char *window, int only) { log_debug("%s: %s", __func__, window); @@ -484,7 +484,7 @@ cmd_find_get_window(struct cmd_find_state *fs, const char *window) return (0); /* Otherwise try as a session itself. */ - if (cmd_find_get_session(fs, window) == 0) { + if (!only && cmd_find_get_session(fs, window) == 0) { fs->wl = fs->s->curw; fs->w = fs->wl->window; if (~fs->flags & CMD_FIND_WINDOW_INDEX) @@ -651,7 +651,7 @@ cmd_find_get_window_with_session(struct cmd_find_state *fs, const char *window) /* Find pane from string. Fills in s, wl, w, wp. */ static int -cmd_find_get_pane(struct cmd_find_state *fs, const char *pane) +cmd_find_get_pane(struct cmd_find_state *fs, const char *pane, int only) { log_debug("%s: %s", __func__, pane); @@ -675,7 +675,7 @@ cmd_find_get_pane(struct cmd_find_state *fs, const char *pane) return (0); /* Otherwise try as a window itself (this will also try as session). */ - if (cmd_find_get_window(fs, pane) == 0) { + if (!only && cmd_find_get_window(fs, pane, 0) == 0) { fs->wp = fs->w->active; return (0); } @@ -982,6 +982,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_find_state *current, struct mouse_event *m; char *colon, *period, *copy = NULL; const char *session, *window, *pane; + int window_only = 0, pane_only = 0; /* Log the arguments. */ if (target == NULL) @@ -1066,13 +1067,17 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_find_state *current, if (colon != NULL && period != NULL) { session = copy; window = colon; + window_only = 1; pane = period; + pane_only = 1; } else if (colon != NULL && period == NULL) { session = copy; window = colon; + window_only = 1; } else if (colon == NULL && period != NULL) { window = copy; pane = period; + pane_only = 1; } else { if (*copy == '$') session = copy; @@ -1179,7 +1184,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_find_state *current, /* No session. If window and pane, try them. */ if (window != NULL && pane != NULL) { /* This will fill in session, winlink and window. */ - if (cmd_find_get_window(fs, window) != 0) + if (cmd_find_get_window(fs, window, window_only) != 0) goto no_window; /* This will fill in pane. */ if (cmd_find_get_pane_with_window(fs, pane) != 0) @@ -1190,7 +1195,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_find_state *current, /* If just window is present, try it. */ if (window != NULL && pane == NULL) { /* This will fill in session, winlink and window. */ - if (cmd_find_get_window(fs, window) != 0) + if (cmd_find_get_window(fs, window, window_only) != 0) goto no_window; fs->wp = fs->wl->window->active; goto found; @@ -1199,7 +1204,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_find_state *current, /* If just pane is present, try it. */ if (window == NULL && pane != NULL) { /* This will fill in session, winlink, window and pane. */ - if (cmd_find_get_pane(fs, pane) != 0) + if (cmd_find_get_pane(fs, pane, pane_only) != 0) goto no_pane; goto found; }