Fix custom diff editor restore and custom names#314582
Merged
mjbvz merged 1 commit intomicrosoft:mainfrom May 6, 2026
Merged
Conversation
Make sure that custom diff editors show custom names such as the `(Indexed)` title that get provides Also makes sure custom diff editors are restored on reload by creating serializers for them
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the custom editor workbench integration so custom editor tabs can pick up caller-provided labels and so custom diff editors can participate in editor restoration after reload. It touches the custom editor resolver path, the editor input types, and the serializer/registration plumbing that lets the workbench reopen these editors.
Changes:
- Seed
CustomEditorInputwith a preferred display name from resolver-provided labels. - Add serializers and editor-pane registrations for inline and side-by-side custom diff editor inputs.
- Thread the new
preferredNamefield through custom editor input creation and simplify readonly capability computation.
Show a summary per file
| File | Description |
|---|---|
src/vs/workbench/contrib/customEditor/browser/customEditors.ts |
Passes resolver labels into custom editor inputs and updates diff/custom-editor construction paths. |
src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.ts |
Adds restore serializers for custom diff inputs and updates existing custom editor restore/create paths. |
src/vs/workbench/contrib/customEditor/browser/customEditorInput.ts |
Extends custom editor input init data with preferredName and uses isReadonly() in capability calculation. |
src/vs/workbench/contrib/customEditor/browser/customEditor.contribution.ts |
Registers the new diff input types with the webview editor pane and serializer registry. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.ts:212
- The side-by-side diff serializer has the same hot-exit gap: it restores the tab shape but never carries the modified document's
backupIdback into model creation. After a window reload, dirty custom diffs reopen against the saved file contents instead of the backup, so unsaved changes are lost.
deserialize(_instantiationService: IInstantiationService, serializedEditorInput: string): EditorInput {
const data: SerializedCustomEditorSideBySideDiff = JSON.parse(serializedEditorInput);
return CustomEditorSideBySideDiffInput.create(this._instantiationService, {
originalResource: URI.revive(data.originalResource),
modifiedResource: URI.revive(data.modifiedResource),
viewType: data.viewType,
label: data.label,
description: data.description,
iconPath: undefined,
diffId: data.diffId,
side: data.side,
}, undefined);
- Files reviewed: 4/4 changed files
- Comments generated: 1
Comment on lines
+153
to
+162
| deserialize(_instantiationService: IInstantiationService, serializedEditorInput: string): EditorInput { | ||
| const data: SerializedCustomEditorDiff = JSON.parse(serializedEditorInput); | ||
| return CustomEditorDiffInput.create(this._instantiationService, { | ||
| originalResource: URI.revive(data.originalResource), | ||
| modifiedResource: URI.revive(data.modifiedResource), | ||
| viewType: data.viewType, | ||
| label: data.label, | ||
| description: data.description, | ||
| iconPath: undefined, | ||
| }, undefined); |
roblourens
approved these changes
May 6, 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.
Make sure that custom diff editors show custom names such as the
(Indexed)title that get providesAlso makes sure custom diff editors are restored on reload by creating serializers for them