fix flickering while working one enter=false floats

some of them are caused by https://github.com/neovim/neovim/issues/15300
some are https://github.com/neovim/neovim/issues/19464
and other unknown bugs too

So as workaround don't update statusline in autocmd context immediately
instead defer the refresh to 50ms later in timer context.

fixes #751 #753 #755
This commit is contained in:
shadmansaleh 2022-07-27 21:51:54 +06:00
parent 5f68f070e4
commit 2d6108e07f
1 changed files with 10 additions and 13 deletions

View File

@ -307,20 +307,17 @@ local function refresh(opts)
opts = { kind = 'tabpage', place = { 'statusline', 'winbar', 'tabline' }, trigger = 'unknown' }
end
-- updating statusline in autocommands context seems to trigger 100 different bugs
-- lets just defer it to a timer context and update there
-- workaround for https://github.com/neovim/neovim/issues/15300
-- workaround for https://github.com/neovim/neovim/issues/19464
if
opts.trigger == 'autocmd'
and vim.api.nvim_win_get_height(vim.api.nvim_get_current_win()) <= 1
and vim.tbl_contains(opts.place, 'winbar')
then
local id
for index, value in ipairs(opts.place) do
if value == 'winbar' then
id = index
break
end
end
table.remove(opts.place, id)
-- workaround for https://github.com/nvim-lualine/lualine.nvim/issues/753
-- workaround for https://github.com/nvim-lualine/lualine.nvim/issues/751
-- workaround for https://github.com/nvim-lualine/lualine.nvim/issues/755
if opts.trigger == 'autocmd' then
opts.trigger = 'timer'
vim.defer_fn(function() M.refresh(opts) end, 50)
return
end
local wins = {}