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

Strange foldtext suffix with tree-sitter #52

Closed stevanmilic closed 2 years ago

stevanmilic commented 2 years ago

Neovim version (nvim -v | head -n1)

head

Operating system/version

macOS 12.4

How to reproduce the issue

image

I'm getting this strange output from time-to-time with tree-sitter provider. I'm not entirely sure if it's related to that provider only, since that's the only I'm using tho. Reloading the buffer makes the folded text correct again.

Expected behavior

For fold text to not have occasional strange suffix.

Actual behavior

Fold text sometimes gets buggy.

kevinhwang91 commented 2 years ago

Look like the buffer is detached and can't be synced.

Make sure lua =require'ufo.bufmanager'.buffers[vim.api.nvim_get_current_buf()].attached output true And lua =require'ufo.bufmanager'.buffers[vim.api.nvim_get_current_buf()]:lines(0, -1) output the synced lines.

Edit: It's your foldtext option that has been changed by another plug.

stevanmilic commented 2 years ago

hmm could be, I've been using pretty-fold before ufo, but I'm not sure how could it affect the foldtext since it's deleted, could be that smth is cached tho

kevinhwang91 commented 2 years ago

It's also a bug for ufo. foldtext and fillchars are global/window options. When BufEnter is fired, ufo should reset them.

This is my mistake after refactoring.

stevanmilic commented 2 years ago

Got it, thanks for quickly resolving these issues 💪🏻