Skip to content

fix(fold): skip foldmethod=diff override on solo-content side of added/deleted files - #305

Merged
dlyongemallo merged 1 commit into
mainfrom
299-code_folding_new_deleted_files
Aug 17, 2026
Merged

fix(fold): skip foldmethod=diff override on solo-content side of added/deleted files#305
dlyongemallo merged 1 commit into
mainfrom
299-code_folding_new_deleted_files

Conversation

@dlyongemallo

Copy link
Copy Markdown
Owner

Fixes #299.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.foldlevel override and passes skip_fold into apply_file_winopts on the solo-content side, filtering out foldmethod/foldenable/foldlevel so 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.

@dlyongemallo
dlyongemallo merged commit 31f3992 into main Aug 17, 2026
9 checks passed
@dlyongemallo
dlyongemallo deleted the 299-code_folding_new_deleted_files branch August 17, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code folding in new/deleted files

2 participants