You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support external diff algorithms in internal diff editor #84981
Openness, extensibility and customisability are the features that keep me coming back to VSCode. Being built upon an OSS core (Electron) was strong evidence of a change of culture at Microsoft.
In that spirit, would you please reconsider the original request from myfairsyer. Different diffing algorithms produce significantly different results and are suited to different purposes. There is no one-size-fits-all solution.
Paraphrasing myfairsyer, please consider abstracting the diff functionality to allow different hunk-list providers. Respecting the algorithm set in Git configuration would be an ideal baseline.
As another example, BeyondCompare allows significant customisation, including 2 of the 4 algorithms offered by Git.
Reacted by Kal Sze, Hermholtz, jayree, Asad Ali, Donald Oakes, Rich W, Tobias Gehring, Zach Ramos, Maciej Łodygowski, Gregorczyk, Tomasz and 155 more
Reacted by Zbigniew Matuszewski, Robert (Jamie) Munro, Lucas Gangstad, @Morelearn, LucyZhu, Donald Oakes, bicofevo, Cris De la Rivera, Richard Cooper, Badr Elmers and 2 more
In my opinion there's a place for API and extensibility here. We could have various diff algorithms available as extensions, in addition to a good set provided right inside VS Code.
Reacted by Robert (Jamie) Munro, David McKee and Milo Mirate
This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.
🙂 This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.
I would like to reference feature request #145068 here (disclaimer: it is taking votes, and I am the author) which may or may not make sense considering when defining an interface for alternative diff algorithms or diff extensions (in which case it might also be implemented independent of the diff algorithm as some kind of post-processing.)
In essence, I propose another change category (in addition to the current ones, which are green = line added and red = line removed). This new category (let's call it gray) shall represent lines which have no other change but being commented out or in (using language-specific grammar rules) with respect to the reference lines, allowing to overscroll them more easily because color and font style encode the only change (enabling/disabling the line).
this is ridiculous; notepad++ compare on the left, vscode compare on the right.
Highlighting inside a line is an Ediff feature. Diff just looks for changed lines, no matter what the algorithm is. The difference between the diff algorithms (the original diff, myers, minimal, patience, histogram) is how the lines between two files are ligned up. So it seems Ediff is being used on the left by notepad++ and not on the right. In Emacs for example you can activate Ediff for displaying a diff / diff3 output (and this is independent from the diff algorithm).
Bump this feature. I got same issue when i started to work with code reviewing of AI slop code (yes, who knew that it's the reason), and it's extremely hard to see, what AI refactored, what moved to other part etc. Histogram diffs work amazingly perfect especially when AI (or any other junior dev with auto fixing tools) writes code and maintainer has to review it somehow.
Henning Dieterichs (@hediet), here is a concrete design for this as a proposed API. Would you accept a PR along these lines? I'm happy to change the design before writing it.
Summary
An extension contributes a diff algorithm, and the built-in diff editor uses it only to compute the diff. Rendering, highlighting and navigation stay as they are. The algorithm is selected in diffEditor.diffAlgorithm next to the built-in ones.
The setting value is "<extension id>:<id>". Contributed algorithms appear in the setting's enum before their extension activates, as editor.defaultFormatter lists formatters.
The implicit activation event is onDiffAlgorithm:<extension id>:<id>, like onTerminalProfile:<id>.
declare module 'vscode'{// https://github.com/microsoft/vscode/issues/84981exportinterfaceDiffAlgorithmOptions{readonlyignoreTrimWhitespace: boolean;/** 0 means no limit. */readonlymaxComputationTimeMs: number;readonlycomputeMoves: boolean;readonlyextendToSubwords: boolean;}/** Half-open UTF-16 offsets into the text passed to `computeDiff`. */exportinterfaceDiffOffsetRange{readonlystart: number;readonlyendExclusive: number;}exportinterfaceDiffReplacement{readonlyrange: DiffOffsetRange;readonlynewText: string;}exportinterfaceDiffMove{readonlyrange: {readonlyoriginal: DiffOffsetRange;readonlymodified: DiffOffsetRange};}exportinterfaceDiffAlgorithmResult{readonlyedits: {readonlyreplacements: readonlyDiffReplacement[]};readonlymoves: readonlyDiffMove[];readonlyhitTimeout: boolean;}exportinterfaceDiffAlgorithmProvider{/** * `original` and `modified` are the documents' lines joined with `\n`. * Replacements must be sorted, non-overlapping and index into `original`. */computeDiff(original: string,modified: string,options: DiffAlgorithmOptions,token: CancellationToken): ProviderResult<DiffAlgorithmResult>;}exportnamespaceworkspace{/** Registers an algorithm the calling extension declares in `contributes.diffAlgorithms`. */exportfunctionregisterDiffAlgorithmProvider(id: string,provider: DiffAlgorithmProvider): Disposable;}}
DiffAlgorithmResult has the same shape as the result of @vscode/diff's computeDiff, so a provider can wrap that package and return its result unchanged.
Architecture
Editor layer
WorkerBasedDocumentDiffProvider already delegates to an IDocumentDiffProvider object. IDocumentDiffFactoryOptions and the option validation would be widened to accept extension ids. The web worker only ever receives built-in names.
The conversion from offset edits to LinesDiff in externalLinesDiffComputer.ts would move into a shared function that both paths use.
The diff cache key would include the algorithm, which it doesn't today.
Workbench
A diffAlgorithms extension point and an IDiffAlgorithmsService would track contributions and registered providers. A workbench contribution would keep the setting's enum in sync.
A workbench IDiffProviderFactoryService would replace the editor's default; its only production caller is diffEditorViewModel.ts. Built-in names take today's worker path. An extension id gets an IDocumentDiffProvider that activates the extension, calls it over RPC, then validates and converts the result.
The RPC has $registerDiffAlgorithmProvider and $unregisterDiffAlgorithmProvider on the main thread and $computeDiff(handle, original, modified, options, token) in the extension host. Documents travel as { uri, versionId } and are read from ExtHostDocuments. Text is sent only for models the extension host doesn't mirror.
Safety
Every call gets the cancellation token and a hard deadline.
A result is accepted only if its replacements are sorted, non-overlapping and in range, and applying them to original gives modified.
A missing provider, an error, a timeout or an invalid result falls back to advanced and notifies the user once.
Scope
First PR: the diff editor only. Quick diff, notebook diffs, chat and mergeEditor.diffAlgorithm can follow separately.
Unit tests: cover the conversion, the provider resolution and the fallback.
API test: in vscode-api-tests, a provider that wraps @vscode/diff must produce the same diff as advanced-external.
Open questions
Which namespace should it live in: workspace, window (like registerTerminalProfileProvider) or languages?
Should the value be "<extension id>:<id>" in diffEditor.diffAlgorithm, or a separate setting?
Should the provider receive strings or TextDocuments? Strings keep @vscode/diff compatibility, while documents save one copy of the text.
Should moves have no inner changes, as advanced-external does today, or should DiffMove get optional replacements?
Should there be one global choice or a per-language setting?
Activity
ksze commentedon Nov 21, 2019
Yep, I agree that VS code should support external diff tools with their known algorithms.
Hermholtz commentedon Nov 29, 2019
I'm missing Git's "patience" algo.
In my opinion there's a place for API and extensibility here. We could have various diff algorithms available as extensions, in addition to a good set provided right inside VS Code.
vscodebot commentedon Jan 15, 2020
This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.
Happy Coding!
vscodebot commentedon Feb 14, 2020
🙂 This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.
Happy Coding!
daevski commentedon Feb 23, 2022
Yeah, this is ridiculous; notepad++ compare on the left, vscode compare on the right.
bersbersbers commentedon Mar 18, 2022
I would like to reference feature request #145068 here (disclaimer: it is taking votes, and I am the author) which may or may not make sense considering when defining an interface for alternative diff algorithms or diff extensions (in which case it might also be implemented independent of the diff algorithm as some kind of post-processing.)
In essence, I propose another change category (in addition to the current ones, which are green = line added and red = line removed). This new category (let's call it gray) shall represent lines which have no other change but being commented out or in (using language-specific grammar rules) with respect to the reference lines, allowing to overscroll them more easily because color and font style encode the only change (enabling/disabling the line).
0dB commentedon Sep 28, 2022
Highlighting inside a line is an Ediff feature. Diff just looks for changed lines, no matter what the algorithm is. The difference between the diff algorithms (the original diff, myers, minimal, patience, histogram) is how the lines between two files are ligned up. So it seems Ediff is being used on the left by notepad++ and not on the right. In Emacs for example you can activate Ediff for displaying a diff / diff3 output (and this is independent from the diff algorithm).
pawk3k commentedon Aug 21, 2023
Do you have any updates on that? Do you have any plans on adding support for external diff tools? 🤔 . I'm thinking more about using difftasctic as a diff tool for vs code.
I'm not the only one here :
https://news.ycombinator.com/item?id=30841244.
https://stackoverflow.com/questions/73671245/how-to-change-the-diff-tool-used-by-vscode-for-git
Also, if anyone knows if it's possible right now, how can we achieve that?
maffinyep commentedon Feb 4, 2025
up
quenbyako commentedon Mar 14, 2026
Bump this feature. I got same issue when i started to work with code reviewing of AI slop code (yes, who knew that it's the reason), and it's extremely hard to see, what AI refactored, what moved to other part etc. Histogram diffs work amazingly perfect especially when AI (or any other junior dev with auto fixing tools) writes code and maintainer has to review it somehow.
zamkorus commentedon Oct 19, 2026
Henning Dieterichs (@hediet), here is a concrete design for this as a proposed API. Would you accept a PR along these lines? I'm happy to change the design before writing it.
Summary
An extension contributes a diff algorithm, and the built-in diff editor uses it only to compute the diff. Rendering, highlighting and navigation stay as they are. The algorithm is selected in
diffEditor.diffAlgorithmnext to the built-in ones.Contribution and API
"<extension id>:<id>". Contributed algorithms appear in the setting's enum before their extension activates, aseditor.defaultFormatterlists formatters.onDiffAlgorithm:<extension id>:<id>, likeonTerminalProfile:<id>.DiffAlgorithmResulthas the same shape as the result of@vscode/diff'scomputeDiff, so a provider can wrap that package and return its result unchanged.Architecture
Editor layer
WorkerBasedDocumentDiffProvideralready delegates to anIDocumentDiffProviderobject.IDocumentDiffFactoryOptionsand the option validation would be widened to accept extension ids. The web worker only ever receives built-in names.LinesDiffinexternalLinesDiffComputer.tswould move into a shared function that both paths use.Workbench
diffAlgorithmsextension point and anIDiffAlgorithmsServicewould track contributions and registered providers. A workbench contribution would keep the setting's enum in sync.IDiffProviderFactoryServicewould replace the editor's default; its only production caller isdiffEditorViewModel.ts. Built-in names take today's worker path. An extension id gets anIDocumentDiffProviderthat activates the extension, calls it over RPC, then validates and converts the result.$registerDiffAlgorithmProviderand$unregisterDiffAlgorithmProvideron the main thread and$computeDiff(handle, original, modified, options, token)in the extension host. Documents travel as{ uri, versionId }and are read fromExtHostDocuments. Text is sent only for models the extension host doesn't mirror.Safety
originalgivesmodified.advancedand notifies the user once.Scope
mergeEditor.diffAlgorithmcan follow separately.vscode-api-tests, a provider that wraps@vscode/diffmust produce the same diff asadvanced-external.Open questions
workspace,window(likeregisterTerminalProfileProvider) orlanguages?"<extension id>:<id>"indiffEditor.diffAlgorithm, or a separate setting?TextDocuments? Strings keep@vscode/diffcompatibility, while documents save one copy of the text.advanced-externaldoes today, or shouldDiffMoveget optionalreplacements?