Skip to content

Conversation

@cole-miller
Copy link
Member

This PR reworks the (still feature-gated) side-by-side diff view to use a different approach to representing the multibuffers on the left- and right-hand sides.

Previously, these two multibuffers used identical sets of buffers and excerpts, and were made to behave differently by adding a new knob to the multibuffer controlling how diffs are displayed. Specifically, the left-hand side multibuffer would filter out the added range of each hunk from the excerpts using a new FilteredInsertedHunk diff transform, and the right-hand side would simply not show the deleted sides of expanded hunks. This approach has some problems:

  • Line numbers, and actions that navigate by line number, behaved incorrectly for the left-hand side.
  • Syntax highlighting and other features that use the buffer syntax tree also behaved incorrectly for the left-hand side.

In this PR, we've switched to using independent buffers to build the left-hand side. These buffers are constructed using the base texts for the corresponding diffs, and their lifecycle is managed by BufferDiff. The red "deleted" regions on the left-hand side are represented by BufferContent diff transforms, not DeletedHunk transforms. This means each excerpt on the left represents a contiguous slice of a single buffer, which fixes the above issues by construction.

The tradeoff with this new approach is that we now have to manually synchronize excerpt ranges from the right side to the left, which we do using BufferDiffSnapshot::row_to_base_text_row.

Release Notes:

  • N/A

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants