Repository navigation
Add external diff renderer support - #365
Merged
Merged
Conversation
Pipe diffs through a user-configured external command (e.g. delta) to get ANSI-colored output, parse it with ansi-sequence-parser, and apply the results as VS Code text decorations on magit diff views. New modules: - diffRenderer: spawns the diff renderer subprocess, parses ANSI tokens into DecorationRange structs - diffDecorations: reassembles per-file diffs with headers, runs them through the renderer, and maps renderer line numbers back to document positions via hunk view ranges - diffWiring: manages decoration lifecycle (create, dispose, refresh); walks only visible (unfolded) hunk views; uses a generation counter to handle racing refreshDecorations calls; registers an onDidChangeTextDocument listener to re-apply decorations on fold toggles and status refreshes Settings (off by default): - magit.use-diff-renderer: enable/disable - magit.diff-renderer-command: full command array (default: delta)
Split on /^diff --git /m instead of the bare substring, since git only emits that token at the start of a diff header line — plain substring matching over-splits when file content contains the same text (e.g. sample diffs embedded in test fixtures). Run with: npm run test-compile && npx vscode-test --grep "diffing commands" Add repro test for stashToMagitChanges diff-header splitting A diff whose added/modified file content itself contains a literal "diff --git a/..." line (e.g. a test fixture with a sample diff) causes stashToMagitChanges to over-split on that substring, so the computed change count no longer matches --name-status and the function returns [] — silently blanking commit/stash detail views.
dandavison
force-pushed
the
diff-renderer
branch
from
September 12, 2026 17:44
77ffa96 to
7bc3b06
Compare
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.
AI-written PR I haven't reviewed this carefully. But I have used it quite a lot. Opening nevertheless, as discussed. Please feel free to push fixup / cleanup commits to this branch.
Makes it possible to use an external tool such as delta to add colors to diffs displayed by edamagit.
Settings:
magit.use-diff-renderer: enable/disable (disabled by default)magit.diff-renderer-command: full command array (default: an appropriate delta command)Known issue
AI-written commit message
Pipe diffs through a user-configured external command (e.g. delta) to get ANSI-colored output, parse it with ansi-sequence-parser, and apply the results as VS Code text decorations on magit diff views.
New modules:
diffRenderer: spawns the diff renderer subprocess, parses ANSI tokens intoDecorationRangestructsdiffDecorations: reassembles per-file diffs with headers, runs them through the renderer, and maps renderer line numbers back to document positions via hunk view rangesdiffWiring: manages decoration lifecycle (create, dispose, refresh); walks only visible (unfolded) hunk views; uses a generation counter to handle racingrefreshDecorationscalls; registers anonDidChangeTextDocumentlistener to re-apply decorations on fold toggles and status refreshes