kevinhwang91 / nvim-ufo

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

Reopening a previously folded (zM) buffer in a split/vsplit doesn't work as expected #177

Closed serranomorante closed 10 months ago

serranomorante commented 10 months ago

Neovim version (nvim -v | head -n1)

nvim 0.10... dev

Operating system/version

arch linux latest

How to reproduce the issue

t-rec_32

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')

-- 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)

nvim --clean +'so mini.lua'

  1. Open a file (sample1.md but any file with "foldable" text will do)
  2. Execute zM to fold everything
  3. split that file/buffer in a new window:2
  4. Go to the new split window:2, and open another file/buffer (sample2.md)
  5. Go back to the first split window:1 (sample1.md) and start to unfold whatever you'd like and make sure to add additional lines of text on those unfolded lines
  6. Go back to the previous split window:2 (sample2.md) and now reopen the previous file (sample1.md) in this split window.
  7. When you do that, notice how the "state" of the folds gets messy ...

Wasn't able to find the ~/.cache/nvim/ufo.log file

Expected behavior

Maybe reopening a previously folded buffer should have the very same fold state in the split/vsplit

Actual behavior

The fold state gets messy after trying to reopen a previously folded buffer

kevinhwang91 commented 10 months ago

upstream issue.