fix: High cpu usage on O-PENDING mode

Mitigation for #967

This happens primarily because of
https://github.com/neovim/neovim/issues/22263

To prevent this from affecting lualine. Mode changed event
for op-pending mode no longer gets scheduled.

As a side effect lualine no longer properly refreshes upon switching
to op-pending mode.
This commit is contained in:
shadmansaleh 2023-02-14 22:59:11 +06:00
parent 0050b30855
commit 2ac8d77575
1 changed files with 9 additions and 1 deletions

View File

@ -337,7 +337,15 @@ local function refresh(opts)
-- https://github.com/nvim-lualine/lualine.nvim/issues/755
-- https://github.com/neovim/neovim/issues/19472
-- https://github.com/nvim-lualine/lualine.nvim/issues/791
if opts.trigger == 'autocmd' and vim.v.event.new_mode ~= 'c' then
if opts.trigger == 'autocmd' and
vim.v.event.new_mode ~= 'c' and
-- scheduling in op-pending mode seems to call the callback forever.
-- so this is restricted in op-pending mode.
-- https://github.com/neovim/neovim/issues/22263
-- https://github.com/nvim-lualine/lualine.nvim/issues/967
-- note this breaks mode component while switching to op-pending mode
not vim.tbl_contains({'no', 'nov', 'noV'}, vim.v.event.new_mode) and
not vim.tbl_contains({'no', 'nov', 'noV'}, vim.v.event.old_mode) then
opts.trigger = 'autocmd_redired'
vim.schedule(function()
M.refresh(opts)