mirror of
https://github.com/neovim/neovim.git
synced 2026-03-31 04:42:03 +00:00
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.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user