aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/embed_spec.lua
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-12-04 09:50:00 +0100
committerbfredl <bjorn.linse@gmail.com>2023-12-06 18:46:39 +0100
commit8f10362cdc5835a1cd86c8195ce8e3b10ab85384 (patch)
treefd0536f05bc312605ef483292346778b51fcaf5a /test/functional/ui/embed_spec.lua
parent040369e1e4b86c4655a6885b36ee89ad4f10ca16 (diff)
downloadrneovim-8f10362cdc5835a1cd86c8195ce8e3b10ab85384.tar.gz
rneovim-8f10362cdc5835a1cd86c8195ce8e3b10ab85384.tar.bz2
rneovim-8f10362cdc5835a1cd86c8195ce8e3b10ab85384.zip
fix(startup): only send one default_colors_set event during startup
If the color scheme is changed in a startup script, nvim used to send multiple default_colors_set events, one for the default color scheme and one for the user's chosen color scheme. This would cause flicker in some UI:s. Throttle this event until we actually start drawing on the screen. fixes #26372
Diffstat (limited to 'test/functional/ui/embed_spec.lua')
-rw-r--r--test/functional/ui/embed_spec.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua
index 3bc3af9853..5917c4fccc 100644
--- a/test/functional/ui/embed_spec.lua
+++ b/test/functional/ui/embed_spec.lua
@@ -143,6 +143,39 @@ describe('--embed UI', function()
{2:-- INSERT --} |
]]}
end)
+
+ it("only sets background colors once even if overridden", function()
+ local screen, current, seen
+ local function handle_default_colors_set(_, _, rgb_bg, _, _, _)
+ seen[rgb_bg] = true
+ current = rgb_bg
+ end
+ local function startup(...)
+ seen = {}
+ current = nil
+ clear {args_rm={'--headless'}, args={...}}
+
+ -- attach immediately after startup, for early UI
+ screen = Screen.new(40, 8)
+ screen._handle_default_colors_set = handle_default_colors_set
+ screen:attach()
+ end
+
+ startup()
+ screen:expect{condition=function()
+ eq(16777215, current)
+ end}
+ eq({[16777215]=true}, seen)
+
+ -- NB: by accident how functional/helpers.lua currently handles the default color scheme, the
+ -- above is sufficient to test the behavior. But in case that workaround is removed, we need
+ -- a test with an explicit override like below, so do it to remain safe.
+ startup('--cmd', 'hi NORMAL guibg=#FF00FF')
+ screen:expect{condition=function()
+ eq(16711935, current)
+ end}
+ eq({[16711935]=true}, seen) -- we only saw the last one, despite 16777215 was set internally earlier
+ end)
end)
describe('--embed --listen UI', function()