From e13e85051751bad2aa8586cf227f73286b2421ed Mon Sep 17 00:00:00 2001 From: Sean Dewar <6256228+seandewar@users.noreply.github.com> Date: Sun, 8 Mar 2026 23:33:01 +0000 Subject: [PATCH] fix(api): redraw after setting minimal style Problem: No explicit redraw after setting style=minimal in nvim_open_win or nvim_win_set_config, which may cause it to appear like it's not set. Solution: call changed_window_setting after applying the style, which should be enough for these options. --- src/nvim/api/win_config.c | 3 +++ test/functional/api/window_spec.lua | 35 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c index 5e22fe591d..7ea46d9059 100644 --- a/src/nvim/api/win_config.c +++ b/src/nvim/api/win_config.c @@ -24,6 +24,7 @@ #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/memory_defs.h" +#include "nvim/move.h" #include "nvim/option.h" #include "nvim/option_vars.h" #include "nvim/pos_defs.h" @@ -345,6 +346,7 @@ Window nvim_open_win(Buffer buffer, Boolean enter, Dict(win_config) *config, Err if (fconfig.style == kWinStyleMinimal) { win_set_minimal_style(wp); didset_window_options(wp, true); + changed_window_setting(wp); } rv = wp->handle; @@ -672,6 +674,7 @@ void nvim_win_set_config(Window window, Dict(win_config) *config, Error *err) if (HAS_KEY_X(config, style) && fconfig.style == kWinStyleMinimal) { win_set_minimal_style(win); didset_window_options(win, true); + changed_window_setting(win); } if (fconfig._cmdline_offset < INT_MAX) { cmdline_win = win; diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index db6e01b2ac..d6178fcfb1 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -2316,6 +2316,41 @@ describe('API/win', function() ) ) end) + + it('redraws after setting minimal style', function() + local screen = Screen.new(10, 10) + -- Autocommand processes pending redraws earlier than when minimal style is set, so it doesn't + -- implicitly rely on those. + exec([[ + set cursorline cursorcolumn number + autocmd WinNew * ++once redraw | let g:triggered = 1 + ]]) + screen:expect([[ + {15: 1 }{21:^ }| + {1:~ }|*8 + | + ]]) + api.nvim_open_win(0, false, { style = 'minimal', split = 'below' }) + eq(1, eval('g:triggered')) + screen:expect([[ + {15: 1 }{21:^ }| + {1:~ }|*2 + {2:[No Name] }| + |*4 + {2:[No Name] }| + | + ]]) + -- Also check nvim_win_set_config: only set style to avoid redraws from other config fields. + api.nvim_win_set_config(0, { style = 'minimal' }) + screen:expect([[ + ^ | + |*2 + {3:[No Name] }| + |*4 + {2:[No Name] }| + | + ]]) + end) end) describe('set_config', function()