Add proposal for custom editor diff/merge priority#315321
Merged
Merged
Conversation
Fixes microsoft#292379 For microsoft#138525 Also related to work in microsoft#315174
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a proposed mechanism for custom editors to use different default priorities depending on whether a resource is opened for editing vs diffing vs merging, addressing scenarios where a custom editor should be default for normal editing but not for diffs/merges.
Changes:
- Adds
diffEditorPriorityandmergeEditorPrioritysupport to registered editors and custom editor contributions. - Updates editor resolution logic to compute an “effective priority” based on editor context (edit/diff/merge).
- Adds initial unit tests for diff-priority resolution and wires up a new
customEditorPriorityAPI proposal placeholder.
Show a summary per file
| File | Description |
|---|---|
| src/vscode-dts/vscode.proposed.customEditorPriority.d.ts | Adds the proposed API placeholder entry for gating the manifest contribution changes. |
| src/vs/platform/extensions/common/extensionsApiProposals.ts | Registers the customEditorPriority proposal so extensions can opt in via enabledApiProposals. |
| src/vs/workbench/services/editor/common/editorResolverService.ts | Extends RegisteredEditorInfo with optional diff/merge priority fields. |
| src/vs/workbench/services/editor/browser/editorResolverService.ts | Adds merge association type and “effective priority” handling for diff/merge resolution. |
| src/vs/workbench/services/editor/test/browser/editorResolverService.test.ts | Adds tests intended to validate diff priority behavior (currently not asserting the right thing). |
| src/vs/workbench/contrib/customEditor/common/extensionPoint.ts | Extends the contributes.customEditors schema with diffEditorPriority/mergeEditorPriority. |
| src/vs/workbench/contrib/customEditor/common/customEditor.ts | Carries diff/merge priority fields through custom editor descriptor/info types. |
| src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.ts | Reads the new contribution fields when the proposal is enabled and maps them to registered editor priorities. |
| src/vs/workbench/contrib/customEditor/browser/customEditors.ts | Passes diff/merge priorities into editor registration with the resolver. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/vs/workbench/services/editor/test/browser/editorResolverService.test.ts:767
- This test currently asserts only that the resolved editor is a
DiffEditorInput, which doesn’t validate the intended behavior (fallback fromdiffEditorPrioritytopriority). To make the test meaningful, assert that the correct registered editor’screateDiffEditorInputfactory was invoked (e.g. with a call counter) and that the other factory was not invoked.
// Diff editor should use custom editor since diffEditorPriority falls back to priority: default
const diffResolution = await service.resolveEditor({
original: { resource: URI.file('my://resource.test-no-diff-priority') },
modified: { resource: URI.file('my://resource.test-no-diff-priority') }
}, part.activeGroup);
assert.ok(diffResolution);
assert.notStrictEqual(typeof diffResolution, 'number');
if (diffResolution !== ResolvedStatus.ABORT && diffResolution !== ResolvedStatus.NONE) {
assert.strictEqual(diffResolution.editor.typeId, 'workbench.editors.diffEditorInput');
diffResolution.editor.dispose();
- Files reviewed: 8/9 changed files
- Comments generated: 3
Comment on lines
275
to
+283
| private getAssociationsForResourceByType(resource: URI, associationType: EditorAssociationType): EditorAssociations { | ||
| if (associationType === EditorAssociationType.Editor) { | ||
| return this.getAssociationsForResource(resource); | ||
| if (associationType === EditorAssociationType.DiffEditor || associationType === EditorAssociationType.MergeEditor) { | ||
| const diffAssociations = this.getAssociationsForResourceFromSetting(resource, diffEditorsAssociationsSettingId); | ||
| if (diffAssociations.length) { | ||
| return diffAssociations; | ||
| } | ||
| } | ||
|
|
||
| const diffAssociations = this.getAssociationsForResourceFromSetting(resource, diffEditorsAssociationsSettingId); | ||
| return diffAssociations.length ? diffAssociations : this.getAssociationsForResource(resource); | ||
| return this.getAssociationsForResource(resource); |
Comment on lines
+716
to
+726
| // Diff editor should NOT use custom editor (diffEditorPriority: option) | ||
| const diffResolution = await service.resolveEditor({ | ||
| original: { resource: URI.file('my://resource.test-diff-priority') }, | ||
| modified: { resource: URI.file('my://resource.test-diff-priority') } | ||
| }, part.activeGroup); | ||
| assert.ok(diffResolution); | ||
| // With diffEditorPriority: option, the custom editor should not be selected as default | ||
| if (diffResolution !== ResolvedStatus.ABORT && diffResolution !== ResolvedStatus.NONE) { | ||
| assert.notStrictEqual(diffResolution.editor.typeId, CUSTOM_EDITOR_INPUT_ID, | ||
| 'Custom editor with diffEditorPriority:option should not be used for diffs'); | ||
| diffResolution.editor.dispose(); |
Comment on lines
+517
to
+526
| private getEffectivePriority(editorInfo: RegisteredEditorInfo, associationType: EditorAssociationType): RegisteredEditorPriority { | ||
| switch (associationType) { | ||
| case EditorAssociationType.DiffEditor: | ||
| return editorInfo.diffEditorPriority ?? editorInfo.priority; | ||
| case EditorAssociationType.MergeEditor: | ||
| return editorInfo.mergeEditorPriority ?? editorInfo.priority; | ||
| default: | ||
| return editorInfo.priority; | ||
| } | ||
| } |
roblourens
approved these changes
May 8, 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 #292379
Also related to work in #315174 and #138525
Let's a custom editor contribution give a different priority for diff/merge editors