Add basic support for custom diff editors#313814
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds initial infrastructure and proposed API to let custom editors participate in diff views, including a custom inline (single webview) diff and a custom side-by-side (two webviews) diff, and wires this up to the Markdown preview as a first adopter.
Changes:
- Introduces proposed API
customEditorDiffsto letCustomReadonlyEditorProvider/CustomTextEditorProviderresolve inline and side-by-side diffs. - Adds new diff-specific editor association setting (
workbench.diffEditorAssociations) and updates editor resolution + tests accordingly. - Implements custom-editor diff inputs + workbench actions/context keys, and updates Markdown preview to render + scroll-sync diff line highlights.
Show a summary per file
| File | Description |
|---|---|
| src/vscode-dts/vscode.proposed.customEditorDiffs.d.ts | New proposed API types and provider methods for custom editor diffs. |
| src/vs/platform/extensions/common/extensionsApiProposals.ts | Registers the new customEditorDiffs proposal. |
| src/vs/workbench/api/common/extHost.protocol.ts | Ext host protocol additions for diff webview resolution and diff capabilities. |
| src/vs/workbench/api/common/extHostCustomEditors.ts | Advertises diff capabilities (behind proposal) and implements $resolveCustomEditor*Diff calls. |
| src/vs/workbench/api/browser/mainThreadCustomEditors.ts | Resolves custom diff webviews (inline + side-by-side) and ensures both diff models are created. |
| src/vs/workbench/contrib/customEditor/common/customEditor.ts | Adds diff-related capabilities flags and a layout enum. |
| src/vs/workbench/contrib/customEditor/browser/customEditors.ts | Creates inline/side-by-side custom diff inputs; reacts to diffEditor.renderSideBySide changes to re-open with new layout. |
| src/vs/workbench/contrib/customEditor/browser/customEditorDiffInput.ts | New editor inputs for custom inline diffs and side-by-side diff sides. |
| src/vs/workbench/common/contextkeys.ts | Extends diff detection via isDiffEditorInput and adds custom-diff context keys. |
| src/vs/workbench/browser/parts/editor/diffEditorCommands.ts | Allows toggling inline/side-by-side for custom diffs using modified resource resolution. |
| src/vs/workbench/browser/parts/editor/editor.contribution.ts | Shows diff toggle + “Reopen as Text” tool item for custom text diff editors. |
| src/vs/workbench/browser/parts/editor/editorActions.ts | Extends “Reopen Editor with Text Editor” to handle diff editor inputs. |
| src/vs/workbench/services/editor/common/editorResolverService.ts | Adds workbench.diffEditorAssociations setting contribution. |
| src/vs/workbench/services/editor/browser/editorResolverService.ts | Uses diff associations for diff inputs and filters candidates to those with createDiffEditorInput. |
| src/vs/workbench/services/editor/test/browser/editorResolverService.test.ts | Adds tests covering diff association precedence/behavior. |
| src/vs/workbench/browser/parts/editor/editorConfiguration.ts | Dynamically registers schema for workbench.diffEditorAssociations. |
| extensions/markdown-language-features/package.json | Enables customEditorDiffs proposed API for Markdown extension; minor icon updates. |
| extensions/markdown-language-features/tsconfig.json | Includes the proposed d.ts for customEditorDiffs. |
| extensions/markdown-language-features/types/previewMessaging.d.ts | Adds lineChanges payload for preview updates. |
| extensions/markdown-language-features/src/preview/previewManager.ts | Implements custom text diff resolve methods for Markdown preview (inline + side-by-side). |
| extensions/markdown-language-features/src/preview/preview.ts | Plumbs lineChanges into preview updates; exposes scroll APIs for diff sync. |
| extensions/markdown-language-features/src/preview/documentRenderer.ts | Passes lineChanges into rendered preview settings. |
| extensions/markdown-language-features/src/preview/lineDiff.ts | Computes added/deleted lines and line mappings (git patch preferred, content fallback). |
| extensions/markdown-language-features/preview-src/settings.ts | Adds lineChanges to preview settings. |
| extensions/markdown-language-features/preview-src/index.ts | Applies diff line decorations in the webview and updates them on content refresh. |
| extensions/markdown-language-features/media/markdown.css | Styles for added/deleted line highlighting in preview. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/customEditor/browser/customEditorDiffInput.ts:178
CustomEditorSideBySideDiffInput.createallocatessideInputviaITextEditorService.createTextEditor, butCustomEditorSideBySideDiffInputnever disposessideInput. This can leak the underlying editor input/resources. Consider overridingdispose()to disposethis.sideInput(and then callsuper.dispose()).
return instantiationService.invokeFunction(accessor => {
const textEditorService = accessor.get(ITextEditorService);
const sideInput = textEditorService.createTextEditor({ resource: init.side === 'original' ? init.originalResource : init.modifiedResource });
const webview = accessor.get(IWebviewService).createWebviewOverlay({
providedViewType: init.viewType,
title: sideInput.getName(),
options: {},
contentOptions: {},
extension: undefined,
});
const input = instantiationService.createInstance(CustomEditorSideBySideDiffInput, init, sideInput, webview);
- Files reviewed: 24/26 changed files
- Comments generated: 2
Contributor
Screenshot ChangesBase: Changed (4)Errored (18)Fixtures that failed to render — no screenshot was produced.
|
bhavyaus
approved these changes
May 5, 2026
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.
For #138525
Fixes #298924
Markdown logic is a bit rough still but basics work. Supports either a custom side-by-side view (with two webview) or a combined diff view
cc @hediet since I know you were interested in this