kevinhwang91 / nvim-ufo

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

foldlevel changed by `zR`, `zM` sometime buggy #7

Closed kevinhwang91 closed 2 years ago

kevinhwang91 commented 2 years ago

Neovim version (nvim -v | head -n1)

NVIM v0.7.0

Operating system/version

ArchLinux

How to reproduce the issue

local function level1()
    local function level2()
        |
    end
end
  1. type zR, foldlevel become 2
  2. change buffer becomes:
    local function level1()
    local function level2()
        if true then
            print('level3')
        end
    end
    end

    and enter normal mode, folds have applied, level3 is closed automatically.

Expected behavior

level 3 fold keeps open.

Actual behavior

image

kevinhwang91 commented 2 years ago

Look like should mock zR and zM behavior but keep foldlevel value. Vim have v:count1 + zr and v:count1 + zm to change foldlevel, not bad to remap zR and zM.

ziontee113 commented 2 years ago

Sorry to ask this but how should I remap zR and zM? I know very little vimscript and I don't know how to use v:count1 + zr.

kevinhwang91 commented 2 years ago

Please update code. use require('ufo').openAllFolds() and require('ufo').closeAllFolds() instead. For now, I leave this issue.

Edit: doc has been updated

ziontee113 commented 2 years ago

Thank you, it's working :+1:

ranjithshegde commented 2 years ago

Could this also be extended for za and zo?

here is the scenario Step 1: open fold using any way other than zr like za or zo Step 2: Insert enter and do stuff step 3: Insert leave. Result, just all folds have closed and i cant see what I just edided so that I can navigate

I think za and zr are important because they only open/close folds under the current cursor position instead of operating onl all folds of the same level in the whole window/buffer

kevinhwang91 commented 2 years ago

Could this also be extended for za and zo?

here is the scenario Step 1: open fold using any way other than zr like za or zo Step 2: Insert enter and do stuff step 3: Insert leave. Result, just all folds have closed and i cant see what I just edided so that I can navigate

I think za and zr are important because they only open/close folds under the current cursor position instead of operating onl all folds of the same level in the whole window/buffer

I think I misunderstand something. Open a new issue, please.

ziontee113 commented 2 years ago

Hi man it was stable before but now when I use zM using require('ufo').closeAllFolds() the terminal freezes (crash) if the foldmethod=marker, it works fine with buffers with foldmethod=manual

kevinhwang91 commented 2 years ago

Hi man it was stable before but now when I use zM using require('ufo').closeAllFolds() the terminal freezes (crash) if the foldmethod=marker, it works fine with buffers with foldmethod=manual

Thanks, update the code please