Revert "Get rid of canHandleDiff"

This reverts commit 6056645892.
This commit is contained in:
Logan Ramos 2021-06-30 12:41:29 -04:00
parent 0760c6f3d0
commit 9b6a9dba52
No known key found for this signature in database
GPG key ID: D9CCFF14F0B18183
6 changed files with 11 additions and 4 deletions

View file

@ -85,6 +85,7 @@ class SearchEditorContribution implements IWorkbenchContribution {
},
{
singlePerResource: true,
canHandleDiff: false,
canSupportResource: resource => (extname(resource) === SEARCH_EDITOR_EXT)
},
({ resource }) => {

View file

@ -169,6 +169,7 @@ export class TerminalService implements ITerminalService {
priority: RegisteredEditorPriority.exclusive
},
{
canHandleDiff: false,
canSupportResource: uri => uri.scheme === Schemas.vscodeTerminal,
singlePerResource: true
},

View file

@ -130,7 +130,8 @@ export class EditorOverrideService extends Disposable implements IEditorOverride
return OverrideStatus.NONE;
}
if (selectedEditor.createDiffEditorInput === undefined && isResourceDiffEditorInput(editor)) {
const handlesDiff = typeof selectedEditor.options?.canHandleDiff === 'function' ? selectedEditor.options.canHandleDiff() : selectedEditor.options?.canHandleDiff;
if (handlesDiff === false && isResourceDiffEditorInput(editor)) {
return OverrideStatus.NONE;
}

View file

@ -82,6 +82,10 @@ export type RegisteredEditorOptions = {
* If your editor cannot be opened in multiple groups for the same resource
*/
singlePerResource?: boolean | (() => boolean);
/**
* If your editor supports diffs
*/
canHandleDiff?: boolean | (() => boolean);
/**
* Whether or not you can support opening the given resource.

View file

@ -39,7 +39,7 @@ suite('EditorOverrideService', () => {
detail: 'Test Editor Details',
priority: RegisteredEditorPriority.default
},
{},
{ canHandleDiff: false },
({ resource, options }, group) => ({ editor: new TestFileEditorInput(URI.parse(resource.toString()), TEST_EDITOR_INPUT_ID) }),
);
@ -63,7 +63,7 @@ suite('EditorOverrideService', () => {
detail: 'Test Editor Details',
priority: RegisteredEditorPriority.default
},
{},
{ canHandleDiff: false },
({ resource, options }, group) => ({ editor: new TestFileEditorInput(URI.parse(resource.toString()), TEST_EDITOR_INPUT_ID) }),
({ resource, options }, group) => ({ editor: new TestFileEditorInput((resource ? resource : URI.from({ scheme: Schemas.untitled })), UNTITLED_TEST_EDITOR_INPUT_ID) }),
);

View file

@ -204,7 +204,7 @@ suite('EditorService', () => {
disposables.add(accessor.editorOverrideService.registerEditor(
'*.editor-service-override-tests',
{ id: TEST_EDITOR_INPUT_ID, label: 'Label', priority: RegisteredEditorPriority.exclusive },
{},
{ canHandleDiff: true },
editor => {
editorFactoryCalled++;
lastEditorFactoryEditor = editor;