Skip to content

[diffs] add folding support#999

Open
ije wants to merge 7 commits into
mainfrom
ije/folding
Open

[diffs] add folding support#999
ije wants to merge 7 commits into
mainfrom
ije/folding

Conversation

@ije

@ije ije commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator
Screenshot 2026-07-17 at 01 21 41
  • Add folding option for File and FileDiff options. (Default is false)
  • Works in edit mode
  • Support both split and unified diffs layouts
  • Support A11y

Usage

new File({
  folding: true,
});

new FileDiff({
  folding: true,
});

@ije
ije requested review from amadeus, mdo and necolas July 16, 2026 17:24
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pierre-docs-diffs Ready Ready Preview Jul 24, 2026 10:36am
pierre-docs-diffshub Ready Ready Preview Jul 24, 2026 10:36am
pierre-docs-trees Ready Ready Preview Jul 24, 2026 10:36am
pierrejs-diff-demo Ready Ready Preview Jul 24, 2026 10:36am

Request Review

@blacksmith-sh

This comment has been minimized.

@ije

ije commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc8ba464f0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

}
return {
startingLine,
totalLines: finalLine - startingLine + 1,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid sending folded bodies through render windows

When a viewport contains both the folded header and the first visible line after a large collapsed body (for example folding lines 1–19990), startingLine can be the header while finalLine is after the fold, so this returns a render window spanning the entire hidden body. FileRenderer.renderFile forwards startingLine/totalLines into windowed plain rendering before it skips foldRanges, which means large folded regions are still sliced/joined/tokenized even though only a few visible rows are needed; please avoid passing hidden spans to the renderer or make that path skip folded bodies.

Useful? React with 👍 / 👎.

Base automatically changed from beta-1.3 to main July 21, 2026 21:25
@tomerzcod7

tomerzcod7 commented Jul 23, 2026

Copy link
Copy Markdown

Hey guys, thanks for working on this - we use your library extensively and this is one feature we've been needing.
Please let me know if this is not the place for a comment like this.

We have a common use case, where we use the React File component as a read-only viewer, particularly for large, pretty-printed JSON files. We’d love to use the new nested folding controls there without enabling edit mode.
Any chances you would be open to support folding for read-only File component as well? maybe via the FileOptions?
Alternatively, is there an intended way to attach the experimental Editor for folding while preventing content edits?

We would love to adopt an experimental version and would be happy to test it and provide feedback.

@ije

ije commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

Any chances you would be open to support folding for read-only File component as well?

this makes sense to me, will support!

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.

3 participants