Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove editorOpenWith #116856

Merged
merged 23 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/vs/platform/editor/common/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ export interface IEditorOptions {
* - `undefined`: let the editor decide for itself
* - `false`: disable overrides
* - `string`: specific override by id
* - `null`: shows a picker for the user to decide
lramos15 marked this conversation as resolved.
Show resolved Hide resolved
lramos15 marked this conversation as resolved.
Show resolved Hide resolved
*/
readonly override?: false | string;
readonly override?: false | string | null;

/**
* A optional hint to signal in which context the editor opens.
Expand Down
7 changes: 2 additions & 5 deletions src/vs/workbench/api/browser/mainThreadNotebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { URI, UriComponents } from 'vs/base/common/uri';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { EditorActivation, ITextEditorOptions } from 'vs/platform/editor/common/editor';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ILogService } from 'vs/platform/log/common/log';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { viewColumnToEditorGroup } from 'vs/workbench/common/editor';
Expand All @@ -28,7 +27,6 @@ import { ACCESSIBLE_NOTEBOOK_DISPLAY_ORDER, CellEditType, DisplayOrderKey, ICell
import { INotebookEditorModelResolverService } from 'vs/workbench/contrib/notebook/common/notebookEditorModelResolverService';
import { IMainNotebookController, INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
import { IEditorGroup, IEditorGroupsService, preferredSideBySideGroupDirection } from 'vs/workbench/services/editor/common/editorGroupsService';
import { openEditorWith } from 'vs/workbench/services/editor/common/editorOpenWith';
import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
Expand Down Expand Up @@ -132,8 +130,7 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
@ILogService private readonly _logService: ILogService,
@INotebookCellStatusBarService private readonly _cellStatusBarService: INotebookCellStatusBarService,
@INotebookEditorModelResolverService private readonly _notebookModelResolverService: INotebookEditorModelResolverService,
@IUriIdentityService private readonly _uriIdentityService: IUriIdentityService,
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@IUriIdentityService private readonly _uriIdentityService: IUriIdentityService
) {
super();
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostNotebook);
Expand Down Expand Up @@ -716,7 +713,7 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
const input = this._editorService.createEditorInput({ resource: URI.revive(resource), options: editorOptions });

// TODO: handle options.selection
const editorPane = await this._instantiationService.invokeFunction(openEditorWith, input, viewType, options, group);
const editorPane = await this._editorService.openEditor(input, { override: viewType, ...options }, group);
const notebookEditor = (editorPane as unknown as { isNotebookEditor?: boolean })?.isNotebookEditor ? (editorPane!.getControl() as INotebookEditor) : undefined;

if (notebookEditor) {
Expand Down
9 changes: 3 additions & 6 deletions src/vs/workbench/browser/parts/editor/editorActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import { ItemActivation, IQuickInputService } from 'vs/platform/quickinput/commo
import { AllEditorsByMostRecentlyUsedQuickAccess, ActiveGroupEditorsByMostRecentlyUsedQuickAccess, AllEditorsByAppearanceQuickAccess } from 'vs/workbench/browser/parts/editor/editorQuickAccess';
import { Codicon } from 'vs/base/common/codicons';
import { IFilesConfigurationService, AutoSaveMode } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
import { openEditorWith, getAllAvailableEditors } from 'vs/workbench/services/editor/common/editorOpenWith';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';

export class ExecuteCommandAction extends Action {

Expand Down Expand Up @@ -1894,8 +1892,7 @@ export class ReopenResourcesAction extends Action {
constructor(
id: string,
label: string,
@IEditorService private readonly editorService: IEditorService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IEditorService private readonly editorService: IEditorService
) {
super(id, label);
}
Expand All @@ -1913,7 +1910,7 @@ export class ReopenResourcesAction extends Action {

const options = activeEditorPane.options;
const group = activeEditorPane.group;
await this.instantiationService.invokeFunction(openEditorWith, activeInput, undefined, options, group);
await this.editorService.openEditor(activeInput, { override: null, ...options }, group);
}
}

Expand Down Expand Up @@ -1944,7 +1941,7 @@ export class ToggleEditorTypeAction extends Action {
const options = activeEditorPane.options;
const group = activeEditorPane.group;

const overrides = getAllAvailableEditors(activeEditorResource, undefined, options, group, this.editorService);
const overrides = this.editorService.getEditorOverrides(activeEditorResource, options, group);
const firstNonActiveOverride = overrides.find(([_, entry]) => !entry.active);
if (!firstNonActiveOverride) {
return;
Expand Down
5 changes: 2 additions & 3 deletions src/vs/workbench/browser/parts/editor/editorCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
import { ActiveGroupEditorsByMostRecentlyUsedQuickAccess } from 'vs/workbench/browser/parts/editor/editorQuickAccess';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { ITextEditorOptions } from 'vs/platform/editor/common/editor';
import { openEditorWith } from 'vs/workbench/services/editor/common/editorOpenWith';

export const CLOSE_SAVED_EDITORS_COMMAND_ID = 'workbench.action.closeUnmodifiedEditors';
export const CLOSE_EDITORS_IN_GROUP_COMMAND_ID = 'workbench.action.closeEditorsInGroup';
Expand Down Expand Up @@ -499,10 +498,10 @@ function registerOpenEditorAPICommands(): void {
group = editorGroupsService.getGroup(viewColumnToEditorGroup(editorGroupsService, columnArg)) ?? editorGroupsService.activeGroup;
}

const textOptions: ITextEditorOptions = optionsArg ? { ...optionsArg, override: false } : { override: false };
const textOptions: ITextEditorOptions = optionsArg ? optionsArg : {};

const input = editorService.createEditorInput({ resource: URI.revive(resource) });
return openEditorWith(accessor, input, id, textOptions, group);
return editorService.openEditor(input, { override: id, ...textOptions }, group);
});
}

Expand Down
26 changes: 23 additions & 3 deletions src/vs/workbench/common/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ActionRunner, IAction } from 'vs/base/common/actions';
import { IFileService } from 'vs/platform/files/common/files';
import { IPathData } from 'vs/platform/windows/common/windows';
import { coalesce, firstOrDefault } from 'vs/base/common/arrays';
import { ACTIVE_GROUP, IResourceEditorInputType, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { ACTIVE_GROUP, ICustomEditorInfo, IResourceEditorInputType, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { IRange } from 'vs/editor/common/core/range';
import { IExtUri } from 'vs/base/common/resources';

Expand Down Expand Up @@ -1009,7 +1009,7 @@ export class EditorOptions implements IEditorOptions {
* - `false`: disable overrides
* - `string`: specific override by id
*/
override?: false | string;
override?: false | string | null;
lramos15 marked this conversation as resolved.
Show resolved Hide resolved

/**
* A optional hint to signal in which context the editor opens.
Expand Down Expand Up @@ -1067,7 +1067,7 @@ export class EditorOptions implements IEditorOptions {
this.index = options.index;
}

if (typeof options.override === 'string' || options.override === false) {
if (typeof options.override === 'string' || options.override === false || options.override === null) {
this.override = options.override;
}

Expand Down Expand Up @@ -1637,3 +1637,23 @@ export function editorGroupToViewColumn(editorGroupService: IEditorGroupsService
}

//#endregion

//#region Editor Open With
lramos15 marked this conversation as resolved.
Show resolved Hide resolved
bpasero marked this conversation as resolved.
Show resolved Hide resolved
export const customEditorsAssociationsSettingId = 'workbench.editorAssociations';

export const builtinProviderDisplayName = localize('builtinProviderDisplayName', "Built-in");

export const DEFAULT_CUSTOM_EDITOR: ICustomEditorInfo = {
id: 'default',
displayName: localize('promptOpenWith.defaultEditor.displayName', "Text Editor"),
providerDisplayName: builtinProviderDisplayName
};

export type CustomEditorAssociation = {
readonly viewType: string;
readonly filenamePattern?: string;
};

export type CustomEditorsAssociations = readonly CustomEditorAssociation[];

////#endregion
lramos15 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
import * as colorRegistry from 'vs/platform/theme/common/colorRegistry';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { EditorInput, EditorOptions, Extensions as EditorInputExtensions, GroupIdentifier, IEditorInput, IEditorInputFactoryRegistry, IEditorPane } from 'vs/workbench/common/editor';
import { CustomEditorAssociation, CustomEditorsAssociations, customEditorsAssociationsSettingId, EditorInput, EditorOptions, Extensions as EditorInputExtensions, GroupIdentifier, IEditorInput, IEditorInputFactoryRegistry, IEditorPane } from 'vs/workbench/common/editor';
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
import { CONTEXT_CUSTOM_EDITORS, CONTEXT_FOCUSED_CUSTOM_EDITOR_IS_EDITABLE, CustomEditorCapabilities, CustomEditorInfo, CustomEditorInfoCollection, CustomEditorPriority, ICustomEditorService } from 'vs/workbench/contrib/customEditor/common/customEditor';
import { CustomEditorModelManager } from 'vs/workbench/contrib/customEditor/common/customEditorModelManager';
import { IWebviewService } from 'vs/workbench/contrib/webview/browser/webview';
import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { CustomEditorAssociation, CustomEditorsAssociations, customEditorsAssociationsSettingId } from 'vs/workbench/services/editor/common/editorOpenWith';
import { ICustomEditorInfo, ICustomEditorViewTypesHandler, IEditorService, IOpenEditorOverride, IOpenEditorOverrideEntry } from 'vs/workbench/services/editor/common/editorService';
import { ContributedCustomEditors, defaultCustomEditor } from '../common/contributedCustomEditors';
import { CustomEditorInput } from './customEditorInput';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ import { URI } from 'vs/base/common/uri';
import * as nls from 'vs/nls';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { builtinProviderDisplayName } from 'vs/workbench/common/editor';
import { Memento } from 'vs/workbench/common/memento';
import { CustomEditorDescriptor, CustomEditorInfo, CustomEditorPriority } from 'vs/workbench/contrib/customEditor/common/customEditor';
import { customEditorsExtensionPoint, ICustomEditorsExtensionPoint } from 'vs/workbench/contrib/customEditor/common/extensionPoint';
import { DEFAULT_EDITOR_ID } from 'vs/workbench/services/editor/common/editorOpenWith';
import { IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry';

const builtinProviderDisplayName = nls.localize('builtinProviderDisplayName', "Built-in");

export const defaultCustomEditor = new CustomEditorInfo({
id: DEFAULT_EDITOR_ID,
id: 'default',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Why does this constant need to be inlined?

Copy link
Member Author

@lramos15 lramos15 Feb 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It breaks layering, as everywhere else this is used is in browser

displayName: nls.localize('promptOpenWith.defaultEditor.displayName', "Text Editor"),
providerDisplayName: builtinProviderDisplayName,
selector: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import { BINARY_FILE_EDITOR_ID } from 'vs/workbench/contrib/files/common/files';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { openEditorWith } from 'vs/workbench/services/editor/common/editorOpenWith';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';

/**
* An implementation of editor for binary files that cannot be displayed.
Expand All @@ -27,7 +26,7 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor {
@ITelemetryService telemetryService: ITelemetryService,
@IThemeService themeService: IThemeService,
@IOpenerService private readonly openerService: IOpenerService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IEditorService private readonly editorService: IEditorService,
@IStorageService storageService: IStorageService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
) {
Expand All @@ -51,7 +50,7 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor {
input.setForceOpenAsText();

// If more editors are installed that can handle this input, show a picker
await this.instantiationService.invokeFunction(openEditorWith, input, undefined, options, this.group);
await this.editorService.openEditor(input, { override: null, ...options }, this.group);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/contrib/files/browser/fileCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
import { openEditorWith } from 'vs/workbench/services/editor/common/editorOpenWith';
import { isPromiseCanceledError } from 'vs/base/common/errors';
import { toAction } from 'vs/base/common/actions';

Expand Down Expand Up @@ -359,7 +358,8 @@ CommandsRegistry.registerCommand({
const uri = getResourceForCommand(resource, accessor.get(IListService), accessor.get(IEditorService));
if (uri) {
const input = editorService.createEditorInput({ resource: uri });
openEditorWith(accessor, input, undefined, undefined, editorGroupsService.activeGroup);
editorService.openEditor(input, { override: null }, editorGroupsService.activeGroup);
lramos15 marked this conversation as resolved.
Show resolved Hide resolved
lramos15 marked this conversation as resolved.
Show resolved Hide resolved
//openEditorWith(accessor, input, undefined, undefined, editorGroupsService.activeGroup);
lramos15 marked this conversation as resolved.
Show resolved Hide resolved
}
}
});
Expand Down Expand Up @@ -680,7 +680,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({

const textInput = editorService.createEditorInput({ options: { pinned: true } });
const group = editorGroupsService.activeGroup;
await openEditorWith(accessor, textInput, args.viewType, { pinned: true }, group);
await editorService.openEditor(textInput, { override: args.viewType, pinned: true }, group);
} else {
await editorService.openEditor({ options: { pinned: true } }); // untitled are always pinned
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle
import { Registry } from 'vs/platform/registry/common/platform';
import { EditorDescriptor, Extensions as EditorExtensions, IEditorRegistry } from 'vs/workbench/browser/editor';
import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
import { EditorInput, Extensions as EditorInputExtensions, ICustomEditorInputFactory, IEditorInput, IEditorInputFactory, IEditorInputFactoryRegistry } from 'vs/workbench/common/editor';
import { CustomEditorsAssociations, customEditorsAssociationsSettingId, EditorInput, Extensions as EditorInputExtensions, ICustomEditorInputFactory, IEditorInput, IEditorInputFactory, IEditorInputFactoryRegistry } from 'vs/workbench/common/editor';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { NotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookEditor';
import { NotebookEditorInput } from 'vs/workbench/contrib/notebook/browser/notebookEditorInput';
Expand All @@ -34,7 +34,6 @@ import { CellKind, CellToolbarLocKey, CellUri, DisplayOrderKey, getCellUndoRedoC
import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IEditorService, IOpenEditorOverride } from 'vs/workbench/services/editor/common/editorService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { CustomEditorsAssociations, customEditorsAssociationsSettingId } from 'vs/workbench/services/editor/common/editorOpenWith';
import { CustomEditorInfo } from 'vs/workbench/contrib/customEditor/common/customEditor';
import { INotebookEditor, IN_NOTEBOOK_TEXT_DIFF_EDITOR, NotebookEditorOptions, NOTEBOOK_EDITOR_OPEN } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { BareFontInfo } from 'vs/editor/common/config/fontInfo';
import { CopyAction, CutAction, PasteAction } from 'vs/editor/contrib/clipboard/clipboard';
import * as nls from 'vs/nls';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { NotebookExtensionDescription } from 'vs/workbench/api/common/extHost.protocol';
import { builtinProviderDisplayName } from 'vs/workbench/common/editor';
import { Memento } from 'vs/workbench/common/memento';
import { INotebookEditorContribution, notebookMarkdownRendererExtensionPoint, notebookProviderExtensionPoint, notebookRendererExtensionPoint } from 'vs/workbench/contrib/notebook/browser/extensionPoint';
import { CellEditState, getActiveNotebookEditor, ICellViewModel, INotebookEditor, NotebookEditorOptions, updateEditorTopPadding } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
Expand Down Expand Up @@ -126,7 +126,7 @@ export class NotebookProviderInfoStore extends Disposable {
priority: this._convertPriority(notebookContribution.priority),
providerExtensionId: extension.description.identifier.value,
providerDescription: extension.description.description,
providerDisplayName: extension.description.isBuiltin ? nls.localize('builtinProviderDisplayName', "Built-in") : extension.description.displayName || extension.description.identifier.value,
providerDisplayName: extension.description.isBuiltin ? builtinProviderDisplayName : extension.description.displayName || extension.description.identifier.value,
providerExtensionLocation: extension.description.extensionLocation,
dynamicContribution: false,
exclusive: false
Expand Down
Loading