kevinhwang91 / nvim-ufo

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

Error when starting neovim whilst restoring a session #48

Closed akinsho closed 2 years ago

akinsho commented 2 years ago

Neovim version (nvim -v | head -n1)

NVIM v0.8.0-dev+2060-g0f1b17788

Operating system/version

macOS 12.4

How to reproduce the issue

cat mini.lua

-- Use Vim packages install the plugin, also work with some plugins manager such as packer.nvim
vim.o.packpath = '~/.local/share/nvim/site'
vim.cmd('packadd promise-async')
vim.cmd('packadd nvim-ufo')
vim.cmd('packadd auto-session')

-- Setting
vim.o.foldcolumn = '1'
vim.o.foldlevel = 99
vim.o.foldlevelstart = -1
vim.o.foldenable = true

local ufo = require('ufo')
ufo.setup()
vim.keymap.set('n', 'zR', ufo.openAllFolds)
vim.keymap.set('n', 'zM', ufo.closeAllFolds)

require('auto-session').setup()

nvim --clean -u mini.lua

  1. Open nvim in a directory and open some files in nvim
  2. Close nvim with some files open (this will create the session on vim leave)
  3. Reopen neovim in the same directory, see error ...

Expected behavior

Since the most recent commit, 8cf1259 when I re-open neovim with a session autoloaded using the https://github.com/rmagatti/auto-session plugin. I encounter the bug described below about the invalid buffer id: 1 I think when restarting a session, some buffers are deleted really quickly before the session restarts.

Actual behavior

Error executing vim.schedule lua callback: UnhandledPromiseRejection with the reason:                                                                                                           
...site/pack/packer/start/nvim-ufo/lua/ufo/model/buffer.lua:17: Invalid buffer id: 1 
kevinhwang91 commented 2 years ago

Thanks, fixed now.