diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2022-06-20 07:59:38 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2022-06-20 07:59:38 +0000 |
commit | 1b5bfba3d0886bbf25c21fd6e17b1a37881b1534 (patch) | |
tree | 329e10f156f861946886cf57b13c3028cc63e1e5 /usr.bin/tmux/cfg.c | |
parent | cf51bafd72f939da660e381e6f3acd3dd24e86ec (diff) |
Do not display configuration file errors in a pane when in control mode,
instead report them with a %config-error notification. GitHub issue 3193.
Diffstat (limited to 'usr.bin/tmux/cfg.c')
-rw-r--r-- | usr.bin/tmux/cfg.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/usr.bin/tmux/cfg.c b/usr.bin/tmux/cfg.c index 34bae6b79a4..286c0017538 100644 --- a/usr.bin/tmux/cfg.c +++ b/usr.bin/tmux/cfg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cfg.c,v 1.85 2022/05/30 13:00:18 nicm Exp $ */ +/* $OpenBSD: cfg.c,v 1.86 2022/06/20 07:59:37 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -52,8 +52,7 @@ cfg_done(__unused struct cmdq_item *item, __unused void *data) return (CMD_RETURN_NORMAL); cfg_finished = 1; - if (!RB_EMPTY(&sessions)) - cfg_show_causes(RB_MIN(sessions, &sessions)); + cfg_show_causes(NULL); if (cfg_item != NULL) cmdq_continue(cfg_item); @@ -239,11 +238,29 @@ cfg_print_causes(struct cmdq_item *item) void cfg_show_causes(struct session *s) { + struct client *c = TAILQ_FIRST(&clients); struct window_pane *wp; struct window_mode_entry *wme; u_int i; - if (s == NULL || cfg_ncauses == 0) + if (cfg_ncauses == 0) + return; + + if (c != NULL && (c->flags & CLIENT_CONTROL)) { + for (i = 0; i < cfg_ncauses; i++) { + control_write(c, "%%config-error %s", cfg_causes[i]); + free(cfg_causes[i]); + } + goto out; + } + + if (s == NULL) { + if (c != NULL && c->session != NULL) + s = c->session; + else + s = RB_MIN(sessions, &sessions); + } + if (s == NULL || s->attached == 0) /* wait for an attached session */ return; wp = s->curw->window->active; @@ -255,6 +272,7 @@ cfg_show_causes(struct session *s) free(cfg_causes[i]); } +out: free(cfg_causes); cfg_causes = NULL; cfg_ncauses = 0; |