From 3be369522b6de38ba08ee50a86a49a9a86af490b Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 3 Nov 2022 08:33:57 +0000 Subject: [PATCH 1/2] Add a -l flag to display-message to disable format expansion, from Aaron Jensen. GitHub issue 3372. --- cmd-display-message.c | 10 +++++++--- tmux.1 | 9 +++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/cmd-display-message.c b/cmd-display-message.c index 7828f694..f5e91020 100644 --- a/cmd-display-message.c +++ b/cmd-display-message.c @@ -39,8 +39,8 @@ const struct cmd_entry cmd_display_message_entry = { .name = "display-message", .alias = "display", - .args = { "ac:d:INpt:F:v", 0, 1, NULL }, - .usage = "[-aINpv] [-c target-client] [-d delay] [-F format] " + .args = { "ac:d:lINpt:F:v", 0, 1, NULL }, + .usage = "[-aIlNpv] [-c target-client] [-d delay] [-F format] " CMD_TARGET_PANE_USAGE " [message]", .target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL }, @@ -132,7 +132,11 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item) return (CMD_RETURN_NORMAL); } - msg = format_expand_time(ft, template); + if (args_has(args, 'l')) + msg = xstrdup(template); + else + msg = format_expand_time(ft, template); + if (cmdq_get_client(item) == NULL) cmdq_error(item, "%s", msg); else if (args_has(args, 'p')) diff --git a/tmux.1 b/tmux.1 index dbfc85b1..36faf683 100644 --- a/tmux.1 +++ b/tmux.1 @@ -5887,7 +5887,7 @@ The following keys are also available: .El .Tg display .It Xo Ic display-message -.Op Fl aINpv +.Op Fl aIlNpv .Op Fl c Ar target-client .Op Fl d Ar delay .Op Fl t Ar target-pane @@ -5909,7 +5909,12 @@ is not given, the option is used; a delay of zero waits for a key press. .Ql N ignores key presses and closes only after the delay expires. -The format of +If +.Fl l +is given, +.Ar message +is printed unchanged. +Otherwise, the format of .Ar message is described in the .Sx FORMATS From 17290b912116c4397620526d43dcf6ddcf0044b7 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 3 Nov 2022 08:41:53 +0000 Subject: [PATCH 2/2] If there are no buffers, reset mode as soon as any key pressed. Fixes crash reported by Gaoyang Zhang in GitHub issue 3373. --- window-buffer.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/window-buffer.c b/window-buffer.c index 544a1155..aac0bc40 100644 --- a/window-buffer.c +++ b/window-buffer.c @@ -508,6 +508,11 @@ window_buffer_key(struct window_mode_entry *wme, struct client *c, struct window_buffer_itemdata *item; int finished; + if (paste_get_top(NULL) == NULL) { + finished = 1; + goto out; + } + finished = mode_tree_key(mtd, c, &key, m, NULL, NULL); switch (key) { case 'e': @@ -534,6 +539,8 @@ window_buffer_key(struct window_mode_entry *wme, struct client *c, finished = 1; break; } + +out: if (finished || paste_get_top(NULL) == NULL) window_pane_reset_mode(wp); else {