summaryrefslogtreecommitdiff
path: root/src/getchar.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-02-10 14:07:41 +0000
committerBram Moolenaar <Bram@vim.org>2022-02-10 14:07:41 +0000
commit74a0a5b26d0180f3ea89e9495dff6a26f0df23cb (patch)
treed991dcc0a35f17657c6f591d51b46dcff9a167b3 /src/getchar.c
parent9da17d7c57071c306565da6a35c3704db1916b78 (diff)
downloadvim-git-74a0a5b26d0180f3ea89e9495dff6a26f0df23cb.tar.gz
patch 8.2.4338: an error from an expression mapping messes up the displayv8.2.4338
Problem: An error from an expression mapping messes up the display. Solution: When the expression results in an empty string return K_IGNORE. In cmdline mode redraw the command line. (closes #9726)
Diffstat (limited to 'src/getchar.c')
-rw-r--r--src/getchar.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/getchar.c b/src/getchar.c
index c7a1cca1a..8513679de 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -2840,6 +2840,7 @@ handle_mapping(
int save_may_garbage_collect = may_garbage_collect;
int was_screen_col = screen_cur_col;
int was_screen_row = screen_cur_row;
+ int prev_did_emsg = did_emsg;
vgetc_busy = 0;
may_garbage_collect = FALSE;
@@ -2852,6 +2853,29 @@ handle_mapping(
windgoto(was_screen_row, was_screen_col);
out_flush();
+ // If an error was displayed and the expression returns an empty
+ // string, generate a <Nop> to allow for a redraw.
+ if (prev_did_emsg != did_emsg
+ && (map_str == NULL || *map_str == NUL))
+ {
+ char_u buf[4];
+
+ vim_free(map_str);
+ buf[0] = K_SPECIAL;
+ buf[1] = KS_EXTRA;
+ buf[2] = KE_IGNORE;
+ buf[3] = NUL;
+ map_str = vim_strsave(buf);
+ if (State & CMDLINE)
+ {
+ // redraw the command below the error
+ msg_didout = TRUE;
+ if (msg_row < cmdline_row)
+ msg_row = cmdline_row;
+ redrawcmd();
+ }
+ }
+
vgetc_busy = save_vgetc_busy;
may_garbage_collect = save_may_garbage_collect;
}