diff options
author | bfredl <bjorn.linse@gmail.com> | 2023-12-06 19:58:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-06 19:58:02 +0100 |
commit | 8bb5089974e14f043a0b0c17e4d38dbd0b9a9ab2 (patch) | |
tree | 98eaefe66e60d1cf3f1b385f4e454817ae29948b /src | |
parent | 08545bd45b80e3056fc8c6c4eb25e2ef1fddd897 (diff) | |
parent | 8f10362cdc5835a1cd86c8195ce8e3b10ab85384 (diff) | |
download | rneovim-8bb5089974e14f043a0b0c17e4d38dbd0b9a9ab2.tar.gz rneovim-8bb5089974e14f043a0b0c17e4d38dbd0b9a9ab2.tar.bz2 rneovim-8bb5089974e14f043a0b0c17e4d38dbd0b9a9ab2.zip |
Merge pull request #26381 from bfredl/delaycolors
fix(startup): only send one default_colors_set event during startup
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ui.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/nvim/ui.c b/src/nvim/ui.c index cb4ebb5c3b..a78a5b077f 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -63,6 +63,7 @@ bool ui_cb_ext[kUIExtCount]; ///< Internalized UI capabilities. static bool has_mouse = false; static int pending_has_mouse = -1; +static bool pending_default_colors = false; static Array call_buf = ARRAY_DICT_INIT; @@ -283,8 +284,21 @@ void ui_schedule_refresh(void) void ui_default_colors_set(void) { - ui_call_default_colors_set(normal_fg, normal_bg, normal_sp, - cterm_normal_fg_color, cterm_normal_bg_color); + // Throttle setting of default colors at startup, so it only happens once + // if the user sets the colorscheme in startup. + pending_default_colors = true; + if (starting == 0) { + ui_may_set_default_colors(); + } +} + +static void ui_may_set_default_colors(void) +{ + if (pending_default_colors) { + pending_default_colors = false; + ui_call_default_colors_set(normal_fg, normal_bg, normal_sp, + cterm_normal_fg_color, cterm_normal_bg_color); + } } void ui_busy_start(void) @@ -442,6 +456,9 @@ void ui_line(ScreenGrid *grid, int row, int startcol, int endcol, int clearcol, flags |= kLineFlagInvalid; } + // set default colors now so that that text won't have to be repainted later + ui_may_set_default_colors(); + size_t off = grid->line_offset[row] + (size_t)startcol; ui_call_raw_line(grid->handle, row, startcol, endcol, clearcol, clearattr, |