folke / edgy.nvim

Easily create and manage predefined window layouts, bringing a new edge to your workflow
Apache License 2.0
840 stars 17 forks source link

bug: High CPU usage with invalid config #49

Closed danields761 closed 1 year ago

danields761 commented 1 year ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.9.2

Operating system/version

Linux 5.15.0-84-generic #93-Ubuntu SMP Tue Sep 5 17:16:10 UTC 2023 GNU/Linux

Describe the bug

Neovim exhibits unusual behavior when an invalid configuration is used. Specifically, instead of encountering an exception during the execution of require"edgy".setup {}, Neovim starts to consume 100% of a CPU's core after certain window manipulations. Additionally, it may freeze on the :q command.

SPOILER Extensive examination revealed the root of the issue. The utility `edgy.util.with_retry` fails to increment the `retries` variable. This results in Neovim entering a perpetual loop of `try -> vim.schedule(try) -> vim.schedule(try) ->...`, effectively rendering it stuck and not displaying an error message to the user.

Steps To Reproduce

  1. Implement a basic configuration:
    local plugs = vim.fn.stdpath("data") .. "/lazy"
    local edgy = plugs .. "/edgy.nvim"
    vim.opt.runtimepath:append(edgy)
    require("edgy").setup({
    // Erroneous configuration
    animate = false,
    bottom = { { ft = "help" }, },
    })
  2. Run a clean instance of Neovim using nvim --clean -u /path/to/cfg.lua.
  3. Issue :h cmd.
  4. Monitor CPU usage using ps -eo %cpu,command | grep nvim.
  5. Optionally, try manipulating more windows (may require configuration adjustment) until Neovim becomes unresponsive to input.

Expected Behavior

Neovim should maintain normal CPU usage and not reach 100% consumption.

Repro

local plugs = vim.fn.stdpath("data") .. "/lazy"
local edgy = plugs .. "/edgy.nvim"
vim.opt.runtimepath:append(edgy)
require("edgy").setup({
    -- Erroneous configuration, should be `{ animate = { enabled = false } }`
    animate = false,
    bottom = { { ft = "help" }, },
})