summaryrefslogtreecommitdiffstats
path: root/cmd-display-message.c
diff options
context:
space:
mode:
authornicm <nicm>2021-04-07 12:49:33 +0000
committernicm <nicm>2021-04-07 12:49:33 +0000
commit1ac47400d296ad3a56e9740f9249175bb59953d5 (patch)
treeda49998f5b1c8960829880d6090218d24df52f79 /cmd-display-message.c
parentba999966768b3ede648a361dd9b17ca81bdda173 (diff)
When display-message used in config file, show the message after the
config file finishes. GitHub issue 2637.
Diffstat (limited to 'cmd-display-message.c')
-rw-r--r--cmd-display-message.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/cmd-display-message.c b/cmd-display-message.c
index fc9c4851..301c1a5e 100644
--- a/cmd-display-message.c
+++ b/cmd-display-message.c
@@ -43,7 +43,7 @@ const struct cmd_entry cmd_display_message_entry = {
.usage = "[-aIpv] [-c target-client] [-d delay] [-F format] "
CMD_TARGET_PANE_USAGE " [message]",
- .target = { 't', CMD_FIND_PANE, 0 },
+ .target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
.flags = CMD_AFTERHOOK|CMD_CLIENT_CFLAG|CMD_CLIENT_CANFAIL,
.exec = cmd_display_message_exec
@@ -73,6 +73,8 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
int flags;
if (args_has(args, 'I')) {
+ if (wp == NULL)
+ return (CMD_RETURN_NORMAL);
if (window_pane_start_input(wp, item, &cause) != 0) {
cmdq_error(item, "%s", cause);
free(cause);
@@ -109,8 +111,10 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
*/
if (tc != NULL && tc->session == s)
c = tc;
- else
+ else if (s != NULL)
c = cmd_find_best_client(s);
+ else
+ c = NULL;
if (args_has(args, 'v'))
flags = FORMAT_VERBOSE;
else
@@ -124,7 +128,9 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
}
msg = format_expand_time(ft, template);
- if (args_has(args, 'p'))
+ if (cmdq_get_client(item) == NULL)
+ cmdq_error(item, "%s", msg);
+ else if (args_has(args, 'p'))
cmdq_print(item, "%s", msg);
else if (tc != NULL)
status_message_set(tc, delay, 0, "%s", msg);