Skip to content

A diff marks the changed words inside a changed line #369

Description

@a-team-app

Context

Part of #179. A changed line in the diff tab is tinted end to end, so you find the actual edit by comparing both sides by eye. This marks the changed words inside a changed line with a stronger background — deeper red on the left, deeper green on the right — like GitHub, JetBrains and delta.

Acceptance criteria

Open a diff (e.g. a file against HEAD) containing edited lines and check:

  • On a line that was edited (shown on both sides), the words that differ have a stronger background than the rest of the line: deeper red on the left, deeper green on the right. The rest of the line keeps today's tint.
  • Syntax colours on marked words are unchanged; only the background differs.
  • A word is a run of letters, digits and _, a run of whitespace, or a single other character: changing count to total in Log(fmt, count) marks only count / total, not the comma or parentheses.
  • Re-indenting a line (only leading whitespace changed) marks nothing extra; a whitespace change in the middle of a line is marked.
  • A line that was mostly rewritten (the two sides share less than 40% of their characters) gets no extra marking, just today's tint.
  • Lines only on one side (added or deleted) look exactly as today.
  • Marking stays correct after scrolling sideways, and after the diff refreshes (e.g. after reverting a hunk or editing the file).
  • Every bundled theme shows the marked words clearly and readably, including the 16-colour ones (Borland, Turbo Pascal) and the light one (Daylight).
  • A user theme that sets VS Code's diffEditor.removedTextBackground / diffEditor.insertedTextBackground uses those colours; one that doesn't still shows marking.

Tests

  • The word splitter: identifiers, punctuation, whitespace runs, Unicode letters, empty lines.
  • The similarity check and the 40% cutoff, at and either side of the boundary.
  • Word ranges produced for typical edits: one word changed, two separate edits on one line, insertion at start/end, leading-whitespace-only change.
  • Ranges are computed once per diff/refresh, not per draw.
  • Theme colour lookup with and without the two keys.
  • AGENTS.md § diff tab updated: what's marked and when.

Out of scope

  • Character-level marking, or a setting to switch words / characters / off.
  • Scrolling sideways to a marked word on Alt+↓ (decided against).
  • Smarter pairing of removed/added lines (today the n-th removed pairs with the n-th added).
  • Syntax-aware / structural diffs.
  • Marking in the editor or its gutter — diff tab only.
  • The page-step change (separate task).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-team:devClaimed by the a-team Dev

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions