fix(fold): skip foldmethod=diff override on solo-content side of added/deleted files - #305
Merged
Merged
Conversation
…ded/deleted files
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #299, where code folding was broken on the content side of added or deleted files. In a two-way diff of a new or deleted file, one pane is nulled, so foldmethod=diff produces no useful folds on the pane that actually has content. The fix detects when the paired window in the layout is nulled and, in that case, leaves the buffer's own folding (ftplugin/treesitter/ufo/etc.) intact instead of forcing diffview's diff-fold winopts.
Changes:
- Added
Window:_paired_side_is_null()to detect when a sibling window in the parent layout is nulled. - Skips the
view.foldleveloverride and passesskip_foldintoapply_file_winoptson the solo-content side, filtering outfoldmethod/foldenable/foldlevelso the buffer's own folding survives. - Added two regression tests covering the nulled-sibling (skip) and non-nulled (apply) cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lua/diffview/scene/window.lua | Adds nulled-sibling detection, skip_fold filtering in apply_file_winopts, and gates the foldlevel override on the solo-content side. |
| lua/diffview/tests/functional/window_spec.lua | Adds regression tests verifying fold options are preserved when a sibling is nulled and still applied otherwise. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Fixes #299.