Skip to content

Commit

Permalink
fix flickering while working one enter=false floats
Browse files Browse the repository at this point in the history
some of them are caused by neovim/neovim#15300
some are neovim/neovim#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
  • Loading branch information
shadmansaleh committed Jul 27, 2022
1 parent 5f68f07 commit 2d6108e
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions lua/lualine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down

0 comments on commit 2d6108e

Please sign in to comment.