Skip to content

Port character-level diff highlights to the side-by-side renderer #56

Description

@Cannon07

Motivation

The inline renderer in lua/code-preview/diff.lua highlights which characters within a changed line differ between the original and proposed content (extmarks with ClaudeDiffInlineAddedText / ClaudeDiffInlineRemovedText priority 200, layered on top of the line-level highlights). The side-by-side renderer relies on Neovim's built-in :diffthis, which only does line-level highlights — character-level changes are not visually distinguished.

Bringing char-level highlights to side-by-side is the only piece of feature-floor parity worth porting between the two renderers (see ADR-0003). Other inline features either already exist for side-by-side via :diffthis (]c / [c navigation) or don't translate to a two-window layout (the custom statuscolumn with old|new line numbers).

Scope

  • Extract char_diff_ranges and the char-extmark application logic from the inline path into something reusable.
  • On the side-by-side renderer (show_diff after the layout == "inline" branch), apply matching extmarks to both the CURRENT and PROPOSED buffers for each changed line pair.
  • The existing line-level diff colouring from :diffthis stays; char-level highlights layer on top at higher priority.

Out of scope

  • New rendering features for side-by-side beyond char-level highlights. After this lands, the side-by-side renderer is feature-floor-complete per ADR-0003 and closed to further additions.
  • Statuscolumn changes — old|new line numbers don't apply to a two-window view.
  • Inline-specific ]c / [c keymaps — side-by-side already gets these from :diffthis.
  • Any change to which renderer is the default layout.

Acceptance

  • Side-by-side previews show character-level highlights on changed lines for both CURRENT and PROPOSED windows, matching the inline renderer's behaviour for the same diff.
  • Highlight groups are configurable from the same highlights.inline (or a sibling) config — no new duplicate config surface.
  • Existing tests pass; a new test covers char-level extmark presence on the side-by-side path.

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

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions