New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression: saving buffer will affect folding #30
Comments
It's expected, using below config to avoid: local ftMap = {
python = ''
}
require('ufo').setup({
provider_selector = function(bufnr, filetype)
return ftMap[filetype]
end
}) ufo only respect |
This sounds overbearing, but I don't think it is necessary to use other foldmethods after the |
Thanks, so it's related to the "fold provider" as in the README: https://github.com/kevinhwang91/nvim-ufo#customize-provider-selector Is the fold provider supposed to invalidate all the existing folds (upon saving) and update to the new fold by default and that's what you intended? What if other foldmethod is used, such as indent/filetype? Would we still lose the fold as soon as folds are updated? I would not agree with the default behavior of losing folds whenever the folds get updated for some reason, but if that's the case I could always disable the fold provider. FYI, I am using |
You can disable all the fold providers if you want. |
Thanks for your reply. What I've learned after reading your comments and documentations carefully again is that So the behavior in this issue seems to be my misunderstanding and now I can get understand why you thought the issue is "non-sense", probably due to my ignorance of how nvim-ufo works and what it expects, but I would like to mention that the mechanism and implementation details are not necessarily crystal clear for end users (from what can be tell from README). With all due respect, I don't think it is a non-sense to feel the unexpected behavior itself where folding is lost whenever saving (regarldess foldmethod=manual or foldmethod=expr) is inconvenient. Anyway, thanks for providing the workaround and your efforts for the great plugin! |
I will add some details on how ufo works after If you have read the codebase of ufo, you will find that ufo has made great efforts to improve its performance and defeat any fold plugins. Theoretically, perf of |
If one uses the |
Can't reproduce it, post your setup.
Increase your foldlevel, Once apply folds with |
My config is very minimal, as in #6: require 'ufo'.setup {
open_fold_hl_timeout = 150,
provider_selector = function(bufnr, filetype)
return {'treesitter', 'indent'}
end,
}
This refers to a logical reasoning that the empty-string provider cannot be used any more because treesitter provider is used instead.
No matter what Please look at the video demonstration: |
Please look at the config #6 I posted carefully.
|
Of course I read them carefully. The effective configs are actually identical, I just wanted to use Having the maximum possible foldlevel What would I be missing? |
open a new issue and use a minimal config please.
Please check out #7, need to remap
Can't fix it, this is the limit of |
OK Thanks. I'd like to mention that the config was already minimal and the issues I am mentioning still lie in the same context. But if you mind, for this issue I'll be just simply sticking to 'NO' fold provider. I know you do have a good, inevitable reason nvim-ufo needs to remap or mimick existing fold-related behaviors (#7) to overcome the limitation, but from an end user's perspective that is not necessarily obvious and such discrepancies can make a confusion. Thanks for your explanation -- look forward to documentation. When the treesitter feature is complete and becomes more stable to use with other bugs you mentioned are fixed, I'll revisit and open a new issue if there is any other problem. |
Will add the document to README later. For me, writing a document is a tough task. |
Neovim version (nvim -v | head -n1)
NVIM v0.8.0-dev+1856-g58323b1fe
Operating system/version
macOS 12
How to reproduce the issue
&foldlevel
remaining unchanged:w
nvim-ufo config is quite minimal, e.g.,
FYI, the file I was working on is a python file where
foldmethod=expr
.Expected behavior
All open/close folds should remain intact and untouched. This would include all folds that were manually opened or closed. This behavior was fine in d99d722.
Actual behavior
Bug: Folds will close (or open) as per the
&foldlevel
variable.After doing git bisect, I think the first commit that breaks the behavior is d0bf0cb.
The text was updated successfully, but these errors were encountered: