fix: preserve manually opened folds after text changes#320
Open
tasso-cs wants to merge 1 commit intokevinhwang91:mainfrom
Open
fix: preserve manually opened folds after text changes#320tasso-cs wants to merge 1 commit intokevinhwang91:mainfrom
tasso-cs wants to merge 1 commit intokevinhwang91:mainfrom
Conversation
When using zM to close all folds (foldlevel=0) and then zo to manually open a fold, editing text would cause the fold to close again. Root cause: 1. syncFoldedLines() wasn't called before getRangesFromExtmarks(), so ufo didn't know about manually opened folds 2. When folds are recreated with foldlevel=0, all folds close, overriding manually opened ones Fix: - Call fb:syncFoldedLines(winid) before getRangesFromExtmarks() to sync ufo's internal state with Vim's actual fold state - After restoring foldlevel, if it's 0, explicitly reopen folds that should stay open (those not in rowPairs)
Author
|
@kevinhwang91 let me know if this is of interest to review / merge. thank you :) |
|
This happens when fully fold is the default too: vim.opt.foldlevelstart = 0 whatever changes I make, x, d, or leave insert mode folds all sections |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When using
zMto close all folds (foldlevel=0) and thenzoto manually open a fold, editing text would cause the fold to close again.Root cause
syncFoldedLines()wasn't called beforegetRangesFromExtmarks(), so ufo didn't know about manually opened foldsfoldlevel=0, all folds close, overriding manually opened onesFix
fb:syncFoldedLines(winid)beforegetRangesFromExtmarks()to sync ufo's internal state with Vim's actual fold stateSteps to reproduce (before fix)
zMto close all foldszoto open one foldxto delete a character)Test plan