Skip to content

feat: fold unchanged inline diff regions - #310

Open
princejoogie wants to merge 1 commit into
dlyongemallo:mainfrom
princejoogie:feat/inline-folds
Open

feat: fold unchanged inline diff regions#310
princejoogie wants to merge 1 commit into
dlyongemallo:mainfrom
princejoogie:feat/inline-folds

Conversation

@princejoogie

Copy link
Copy Markdown

Adds an opt-in view.inline.fold_unchanged setting for diff1_inline, using the context from diffopt and the configured view.foldlevel.

This uses foldmethod=expr instead of manual folds so edits and renderer repaints can recompute fold boundaries from the current hunks. Pure-deletion anchors stay at fold level 0, which keeps their deleted virt_lines visible.

Tests:

  • inline renderer, config, and layout specs pass
  • config schema check passes
  • full suite has 10 existing environment failures because jj and hg are not installed

Use expression folds so edits can recompute visible hunk context without rebuilding manual folds. Keep pure-deletion anchors open so deleted virtual lines remain visible.
-- `_repaint`.
local new_lines = self.b.file.nulled and {} or api.nvim_buf_get_lines(bufnr, 0, -1, false)
inline_diff.render(bufnr, old_lines, new_lines, render_opts(self.b.id))
self:_update_folds()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Isn't this going to cause conflicts with user-initiated manual folds? If the user does zo, on the next _repaint this call applies zX and closes their fold.

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.

2 participants