aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuuk van Baal <luukvbaal@gmail.com>2024-05-09 18:12:44 +0200
committerLuuk van Baal <luukvbaal@gmail.com>2024-05-10 14:13:02 +0200
commitfd50185492c7c5b042cc81fe1fde882bcff03c1b (patch)
tree548089c160ccb5f8c529bb17276a385f600af4c9
parent064f3e42e8d33b0a9e560dfb7c9a42b2fc1ed868 (diff)
downloadrneovim-fd50185492c7c5b042cc81fe1fde882bcff03c1b.tar.gz
rneovim-fd50185492c7c5b042cc81fe1fde882bcff03c1b.tar.bz2
rneovim-fd50185492c7c5b042cc81fe1fde882bcff03c1b.zip
fix(tui): initialize clear attrs with current terminal background
Problem: Invalidated regions that are flushed during startup are cleared with unitialized "clear_attrs", which is perceived as flickering. Solution: Initialize "clear_attrs" with current terminal background color.
-rw-r--r--src/nvim/tui/tui.c10
-rw-r--r--test/functional/terminal/tui_spec.lua33
2 files changed, 43 insertions, 0 deletions
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index e1bb1e55e3..10f5ed32b0 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -23,6 +23,7 @@
#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/grid_defs.h"
+#include "nvim/highlight.h"
#include "nvim/highlight_defs.h"
#include "nvim/log.h"
#include "nvim/macros_defs.h"
@@ -165,6 +166,15 @@ void tui_start(TUIData **tui_p, int *width, int *height, char **term, bool *rgb)
tui->seen_error_exit = 0;
tui->loop = &main_loop;
tui->url = -1;
+ // Because setting the default colors is delayed until after startup to avoid
+ // flickering with the default colorscheme background, any flush that happens
+ // during startup in turn would result in clearing invalidated regions with
+ // uninitialized attrs(black). Instead initialize clear_attrs with current
+ // terminal background so that it is at least not perceived as flickering, even
+ // though it may be different from the colorscheme that is set during startup.
+ tui->clear_attrs.rgb_bg_color = normal_bg;
+ tui->clear_attrs.cterm_bg_color = (int16_t)cterm_normal_bg_color;
+
kv_init(tui->invalid_regions);
kv_init(tui->urlbuf);
signal_watcher_init(tui->loop, &tui->winch_handle, tui);
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index f2f4f356be..d4628ea626 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -2003,6 +2003,39 @@ describe('TUI', function()
]])
end)
+ it('invalidated regions are cleared with terminal background attr', function()
+ local screen = Screen.new(50, 10)
+ screen:set_default_attr_ids({ [1] = { foreground = Screen.colors.Black } })
+ screen:attach()
+ fn.termopen({
+ nvim_prog,
+ '--clean',
+ '--cmd',
+ 'set termguicolors',
+ '--cmd',
+ 'sleep 10',
+ }, {
+ env = {
+ VIMRUNTIME = os.getenv('VIMRUNTIME'),
+ },
+ })
+ screen:expect({
+ grid = [[
+ {1:^ }|
+ {1: }|*8
+ |
+ ]],
+ })
+ screen:try_resize(51, 11)
+ screen:expect({
+ grid = [[
+ {1:^ }|
+ {1: }|*9
+ |
+ ]],
+ })
+ end)
+
it('argv[0] can be overridden #23953', function()
if not exec_lua('return pcall(require, "ffi")') then
pending('missing LuaJIT FFI')