Skip to content

Feature: disable line matching in split diffs #781

@barrettruth

Description

@barrettruth

Prerequisites

Proposal

Add an option to render split diffs without pairing deleted and added lines into the same row.

Proposed API:

splitLineMatching?: "paired" | "none"

Example patch:

@@ -1,2 +1,2 @@
 const value = getOldValue()
-return oldValue + 1
+return getNewValue(input) + 1

Current paired split layout:

old new │ old side               │ new side
2   2   │ - return oldValue + 1  │ + return getNewValue(input) + 1

With splitLineMatching: "none":

old new │ old side               │ new side
2       │ - return oldValue + 1  │
    2   │                        │ + return getNewValue(input) + 1

Motivation and context

I can't exactly recall where I've seen this diffing mode, but I like it/use it. The closest precedent is Gitea/Forgejo. Gitea describes this as "matching up added and deleted lines" in split diffs, and moved that matching from client-side JS into the renderer in go-gitea/gitea#16775..

Diff2Html exposes a similar concept directly as matching: 'lines' | 'words' | 'none'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions