diff options
author | 2019-11-14 08:00:30 +0000 | |
---|---|---|
committer | 2019-11-14 08:00:30 +0000 | |
commit | 53fa23261fad20c6b5ebb79c299c19473f07997b (patch) | |
tree | 95eb40632cb2289425d9162583be36900291f772 | |
parent | CUB and CUF are also limited by the margins so use CUP instead when (diff) | |
download | wireguard-openbsd-53fa23261fad20c6b5ebb79c299c19473f07997b.tar.xz wireguard-openbsd-53fa23261fad20c6b5ebb79c299c19473f07997b.zip |
Change new-session -A without a session name (that is, no -s option
also) to attach to the best existing session like attach-session rather
than creating a new one.
-rw-r--r-- | usr.bin/tmux/cmd-new-session.c | 35 | ||||
-rw-r--r-- | usr.bin/tmux/input.c | 4 |
2 files changed, 22 insertions, 17 deletions
diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c index 0421d4aedf3..399dacb9e15 100644 --- a/usr.bin/tmux/cmd-new-session.c +++ b/usr.bin/tmux/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-session.c,v 1.121 2019/09/19 09:02:30 nicm Exp $ */ +/* $OpenBSD: cmd-new-session.c,v 1.122 2019/11/14 08:00:30 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -94,26 +94,31 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item) return (CMD_RETURN_ERROR); } - if (args_has(args, 's')) { - newname = format_single(item, args_get(args, 's'), c, NULL, - NULL, NULL); + tmp = args_get(args, 's'); + if (tmp != NULL) { + newname = format_single(item, tmp, c, NULL, NULL, NULL); if (!session_check_name(newname)) { cmdq_error(item, "bad session name: %s", newname); goto fail; } - if ((as = session_find(newname)) != NULL) { - if (args_has(args, 'A')) { - retval = cmd_attach_session(item, - newname, args_has(args, 'D'), - args_has(args, 'X'), 0, NULL, - args_has(args, 'E')); - free(newname); - return (retval); - } - cmdq_error(item, "duplicate session: %s", newname); - goto fail; + } + if (args_has(args, 'A')) { + if (newname != NULL) + as = session_find(newname); + else + as = item->target.s; + if (as != NULL) { + retval = cmd_attach_session(item, as->name, + args_has(args, 'D'), args_has(args, 'X'), 0, NULL, + args_has(args, 'E')); + free(newname); + return (retval); } } + if (newname != NULL && session_find(newname) != NULL) { + cmdq_error(item, "duplicate session: %s", newname); + goto fail; + } /* Is this going to be part of a session group? */ group = args_get(args, 't'); diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c index 5bffef2b698..4ae151c15ad 100644 --- a/usr.bin/tmux/input.c +++ b/usr.bin/tmux/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.163 2019/11/01 09:09:53 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.164 2019/11/14 08:00:30 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -876,7 +876,7 @@ input_set_state(struct window_pane *wp, const struct input_transition *itr) void input_parse(struct window_pane *wp) { - struct evbuffer *evb = wp->event->input; + struct evbuffer *evb = wp->event->input; input_parse_buffer(wp, EVBUFFER_DATA(evb), EVBUFFER_LENGTH(evb)); evbuffer_drain(evb, EVBUFFER_LENGTH(evb)); |