fix(folds): recompute fold boundaries on TODO state change#1078
fix(folds): recompute fold boundaries on TODO state change#1078seflue wants to merge 2 commits intonvim-orgmode:masterfrom
Conversation
|
Thanks for the PR! Even though this fixes that specific issue, I think it might introduce some other issues. I'm not really a user of folds, but can you clarify when the issue happens more often, when doing todo change on the closed fold or on the opened fold? |
|
It actually happens all the time, when manipulating a folded headline. This is the reason, why I added this test. |
6646332 to
2a2c013
Compare
Summary
This PR fixes fold corruption that occurs when cycling TODO states on folded headlines. When a TODO state change triggers line insertions (CLOSED timestamps, notes) or removals, Neovim's fold boundaries become stale, causing visual glitches or incorrect fold behavior. The fix captures the fold state before modifications, recomputes folds via
zx, and restores the original fold state.Related Issues
Changes
recompute_folds()helper function that recomputes fold boundaries and restores current fold state_todo_change_state()recompute_folds()at all exit points (same-group transitions, done/undone transitions, repeater handling)Checklist
I confirm that I have:
Conventional Commits
specification (e.g.,
feat: add new feature,fix: correct bug,docs: update documentation).make test.