kevinhwang91 / nvim-ufo

Not UFO in the sky, but an ultra fold in Neovim.
BSD 3-Clause "New" or "Revised" License
2.37k stars 49 forks source link

Error creating a split if fold exist #239

Open nicolas-sabbatini opened 4 months ago

nicolas-sabbatini commented 4 months ago

Neovim version (nvim -v | head -n1)

NVIM v0.10.1

Operating system/version

Pop!_OS 22.04 LTS

How to reproduce the issue

{
    "kevinhwang91/nvim-ufo",
    dependencies = { "kevinhwang91/promise-async" },
    config = function()
        require("ufo").setup({
            provider_selector = function()
                return { "treesitter", "indent" }
            end,
        })
    end,
}
  1. Open a file
  2. Create a fold
  3. Create a split (<C-w>v)

step-1 step-2 step-3

Expected behavior

The split is created successfully

Actual behavior

An error is trow

E5108: Error executing lua ...co/.local/share/nvim/lazy/nvim-ufo/lua/ufo/decorator.lua:211: attempt to index field 'foldedPairs' (a nil value)
stack traceback:
        ...co/.local/share/nvim/lazy/nvim-ufo/lua/ufo/decorator.lua:211: in function 'getVirtTextAndCloseFold'
        /home/nico/.local/share/nvim/lazy/nvim-ufo/lua/ufo/main.lua:189: in function </home/nico/.local/share/nvim/lazy/nvim-ufo/lua/ufo/main.lua:186>
kevinhwang91 commented 4 months ago

can't reproduce. foldedPairs never become nil if https://github.com/kevinhwang91/nvim-ufo/blob/1b5f2838099f283857729e820cc05e2b19df7a2c/lua/ufo/decorator.lua#L339

is fired. I don't know why you encounter this error. The foldtext should render after nvim_set_decoration_provider.on_win.

nicolas-sabbatini commented 4 months ago

I found the problem, it was the following option on my config:

vim.opt.debug = "msg" -- Show error messages

If I turn off the option the error disappear

kevinhwang91 commented 3 months ago

still unable to reproduce.