feat(code-editor): add collapse unchanged lines extension with expand…#1342
Merged
jonathanlab merged 4 commits intoPostHog:mainfrom Mar 31, 2026
Merged
feat(code-editor): add collapse unchanged lines extension with expand…#1342jonathanlab merged 4 commits intoPostHog:mainfrom
jonathanlab merged 4 commits intoPostHog:mainfrom
Conversation
4e94d73 to
4ae9a13
Compare
jonathanlab
reviewed
Mar 31, 2026
Contributor
jonathanlab
left a comment
There was a problem hiding this comment.
Thank you! I ran into some smaller issues:
- expand up and expand down seem to do the opposite of what they're supposed to do (expandDown for example reveals the top)
- this does not work in split view, only in unified view.
- It wasn't entirely clear to me that clicking the line count would expand the entire section if we could expand both up and down
- We should indicate how many lines the user will expand if they can expand up and down.
I'll make some small adjustments then merge it!
283e948 to
ffa0f0e
Compare
Contributor
ffa0f0e to
98ec4e6
Compare
Contributor
Author
|
Thanks for the follow up, @jonathanlab! The updated version looks much cleaner. I don’t know why, but I definitely had a "wires crossed" moment with those expand directions, I might have changed them 3 or 4 times. Thanks for straightening that out! Appreciate you jumping in to polish those bits. |
jonathanlab
approved these changes
Mar 31, 2026
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.

Problem
The built-in
collapseUnchangedoption from@codemirror/mergedoesn't support gradual expand controls (expand up/down N lines). Users viewing diffs with large unchanged regions had no way to incrementally reveal context; they could only see the collapsed placeholder or load full ranges of unchanged lines between diffs.Closes #1341
Changes
collapseUnchangedwith an expand-enabled collapse widget. Unchanged regions are collapsed with up/down arrow buttons to expand 20 lines at a time, plus a "N unchanged lines" label that expands all. Expand actions are synced across both sides of split-merge views viamergeViewSiblings.collapseUnchangedconfig and wired the new extension into both split and unified merge views. The extension is skipped whenloadFullFilesis true..cm-collapsedLinesgradient styles with new.cm-collapsed-context,.cm-collapsed-gutter,.cm-collapsed-expand-btn, and.cm-collapsed-labelstyles supporting light/dark themes with hover states.mapPosBetweenSides,buildDecorations,applyExpandEffect(expand up/down/all), andcomputeInitialRanges(mocked viabuildDecorationsassertions).How did you test this?
loadFullFilestoggledFeature Examples
Before
After