diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-10-07 07:52:14 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-10-07 07:52:14 +0000 |
commit | 22a4cd0a1a2178ecb90b8841cf8338e7097c3234 (patch) | |
tree | 48c1900d42ac468976b3a1b4c2dcf97b06a17afa /usr.bin/tmux | |
parent | 43e009eed42a65f9242b8ca7a8e5c506b0e5bcae (diff) |
Handle splitw -I correctly when used from an attached client, GitHub
issue 2917.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/cmd-display-message.c | 10 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-split-window.c | 28 | ||||
-rw-r--r-- | usr.bin/tmux/window.c | 8 |
3 files changed, 30 insertions, 16 deletions
diff --git a/usr.bin/tmux/cmd-display-message.c b/usr.bin/tmux/cmd-display-message.c index 23baf27846b..b5270b359c6 100644 --- a/usr.bin/tmux/cmd-display-message.c +++ b/usr.bin/tmux/cmd-display-message.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-display-message.c,v 1.60 2021/08/21 10:22:39 nicm Exp $ */ +/* $OpenBSD: cmd-display-message.c,v 1.61 2021/10/07 07:52:13 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -75,12 +75,16 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item) if (args_has(args, 'I')) { if (wp == NULL) return (CMD_RETURN_NORMAL); - if (window_pane_start_input(wp, item, &cause) != 0) { + switch (window_pane_start_input(wp, item, &cause)) { + case -1: cmdq_error(item, "%s", cause); free(cause); return (CMD_RETURN_ERROR); + case 1: + return (CMD_RETURN_NORMAL); + case 0: + return (CMD_RETURN_WAIT); } - return (CMD_RETURN_WAIT); } if (args_has(args, 'F') && count != 0) { diff --git a/usr.bin/tmux/cmd-split-window.c b/usr.bin/tmux/cmd-split-window.c index 4c71c474ef2..fbe1f6d1b10 100644 --- a/usr.bin/tmux/cmd-split-window.c +++ b/usr.bin/tmux/cmd-split-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-split-window.c,v 1.110 2021/08/27 17:25:55 nicm Exp $ */ +/* $OpenBSD: cmd-split-window.c,v 1.111 2021/10/07 07:52:13 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -163,16 +163,22 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item) environ_free(sc.environ); return (CMD_RETURN_ERROR); } - if (input && window_pane_start_input(new_wp, item, &cause) != 0) { - server_client_remove_pane(new_wp); - layout_close_pane(new_wp); - window_remove_pane(wp->window, new_wp); - cmdq_error(item, "%s", cause); - free(cause); - if (sc.argv != NULL) - cmd_free_argv(sc.argc, sc.argv); - environ_free(sc.environ); - return (CMD_RETURN_ERROR); + if (input) { + switch (window_pane_start_input(new_wp, item, &cause)) { + case -1: + server_client_remove_pane(new_wp); + layout_close_pane(new_wp); + window_remove_pane(wp->window, new_wp); + cmdq_error(item, "%s", cause); + free(cause); + if (sc.argv != NULL) + cmd_free_argv(sc.argc, sc.argv); + environ_free(sc.environ); + return (CMD_RETURN_ERROR); + case 1: + input = 0; + break; + } } if (!args_has(args, 'd')) cmd_find_from_winlink_pane(current, wl, new_wp, 0); diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index 4d0c9e2bcc2..e4a45ce7535 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.276 2021/08/27 17:15:57 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.277 2021/10/07 07:52:13 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1527,7 +1527,7 @@ window_pane_input_callback(struct client *c, __unused const char *path, size_t len = EVBUFFER_LENGTH(buffer); wp = window_pane_find_by_id(cdata->wp); - if (wp == NULL || closed || error != 0 || c->flags & CLIENT_DEAD) { + if (wp == NULL || closed || error != 0 || (c->flags & CLIENT_DEAD)) { if (wp == NULL) c->flags |= CLIENT_EXIT; @@ -1553,6 +1553,10 @@ window_pane_start_input(struct window_pane *wp, struct cmdq_item *item, *cause = xstrdup("pane is not empty"); return (-1); } + if (c->flags & (CLIENT_DEAD|CLIENT_EXITED)) + return (1); + if (c->session != NULL) + return (1); cdata = xmalloc(sizeof *cdata); cdata->item = item; |