aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/getchar.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-02-09 20:56:30 +0100
committerbfredl <bjorn.linse@gmail.com>2023-02-09 21:39:56 +0100
commit30b29a36e80bfeed50bb6ea618401fe35100490f (patch)
tree54aa923c968f95a89ff3c8c10ba4fdc7d26dadff /src/nvim/getchar.c
parent257765d9e0f20dc060f496ed400b16203e44dc9c (diff)
downloadrneovim-30b29a36e80bfeed50bb6ea618401fe35100490f.tar.gz
rneovim-30b29a36e80bfeed50bb6ea618401fe35100490f.tar.bz2
rneovim-30b29a36e80bfeed50bb6ea618401fe35100490f.zip
refactor(ui): remove some superfluous ui_flush() calls
- <expr> mapping has no business saving and restoring the low-level UI cursor. The cursor will be put in a reasonable position after input is processed, chill out. - TUI handles output needed for suspend - vgetc() family of function does flushing
Diffstat (limited to 'src/nvim/getchar.c')
-rw-r--r--src/nvim/getchar.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 8ed9381bca..f5728d29c1 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -2218,9 +2218,6 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
if (mp->m_expr) {
const int save_vgetc_busy = vgetc_busy;
const bool save_may_garbage_collect = may_garbage_collect;
- const int save_cursor_row = ui_current_row();
- const int save_cursor_col = ui_current_col();
- const handle_T save_cursor_grid = ui_cursor_grid();
const int prev_did_emsg = did_emsg;
vgetc_busy = 0;
@@ -2232,28 +2229,28 @@ static int handle_mapping(int *keylenp, const bool *timedout, int *mapdepth)
}
map_str = eval_map_expr(mp, NUL);
- // The mapping may do anything, but we expect it to take care of
- // redrawing. Do put the cursor back where it was.
- ui_grid_cursor_goto(save_cursor_grid, save_cursor_row, save_cursor_col);
- ui_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 buf[4];
- xfree(map_str);
- buf[0] = (char)K_SPECIAL;
- buf[1] = (char)KS_EXTRA;
- buf[2] = KE_IGNORE;
- buf[3] = NUL;
- map_str = xstrdup(buf);
- if (State & MODE_CMDLINE) {
- // redraw the command below the error
- msg_didout = true;
- if (msg_row < cmdline_row) {
- msg_row = cmdline_row;
+ if ((map_str == NULL || *map_str == NUL)) {
+ // 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) {
+ char buf[4];
+ xfree(map_str);
+ buf[0] = (char)K_SPECIAL;
+ buf[1] = (char)KS_EXTRA;
+ buf[2] = KE_IGNORE;
+ buf[3] = NUL;
+ map_str = xstrdup(buf);
+ if (State & MODE_CMDLINE) {
+ // redraw the command below the error
+ msg_didout = true;
+ if (msg_row < cmdline_row) {
+ msg_row = cmdline_row;
+ }
+ redrawcmd();
}
- redrawcmd();
+ } else if (State & (MODE_NORMAL | MODE_INSERT)) {
+ // otherwise, just put back the cursor
+ setcursor();
}
}