Skip to content

Commit 9025542

Browse files
committed
💄 enum
1 parent fb0ed65 commit 9025542

8 files changed

Lines changed: 24 additions & 24 deletions

File tree

src/vs/workbench/browser/parts/editor/editor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { GroupIdentifier, IWorkbenchEditorConfiguration, EditorOptions, TextEditorOptions, IEditorInput, IEditorIdentifier, IEditorCloseEvent, IEditorPane, IEditorPartOptions, IEditorPartOptionsChangeEvent, EditorInput } from 'vs/workbench/common/editor';
77
import { EditorGroup } from 'vs/workbench/common/editor/editorGroup';
8-
import { IEditorGroup, GroupDirection, IAddGroupOptions, IMergeGroupOptions, GroupsOrder, GroupsArrangement, OpenEditorInGroupContext } from 'vs/workbench/services/editor/common/editorGroupsService';
8+
import { IEditorGroup, GroupDirection, IAddGroupOptions, IMergeGroupOptions, GroupsOrder, GroupsArrangement, OpenEditorContext } from 'vs/workbench/services/editor/common/editorGroupsService';
99
import { IDisposable } from 'vs/base/common/lifecycle';
1010
import { Dimension } from 'vs/base/browser/dom';
1111
import { Event } from 'vs/base/common/event';
@@ -92,7 +92,7 @@ export interface IEditorOpeningEvent extends IEditorIdentifier {
9292
/**
9393
* Context indicates how the editor open event is initialized.
9494
*/
95-
context?: OpenEditorInGroupContext;
95+
context?: OpenEditorContext;
9696

9797
/**
9898
* Allows to prevent the opening of an editor by providing a callback

src/vs/workbench/browser/parts/editor/editorGroupView.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { attachProgressBarStyler } from 'vs/platform/theme/common/styler';
1616
import { IThemeService, registerThemingParticipant, Themable } from 'vs/platform/theme/common/themeService';
1717
import { editorBackground, contrastBorder } from 'vs/platform/theme/common/colorRegistry';
1818
import { EDITOR_GROUP_HEADER_TABS_BACKGROUND, EDITOR_GROUP_HEADER_NO_TABS_BACKGROUND, EDITOR_GROUP_EMPTY_BACKGROUND, EDITOR_GROUP_FOCUSED_EMPTY_BORDER, EDITOR_GROUP_HEADER_BORDER } from 'vs/workbench/common/theme';
19-
import { IMoveEditorOptions, ICopyEditorOptions, ICloseEditorsFilter, IGroupChangeEvent, GroupChangeKind, GroupsOrder, ICloseEditorOptions, ICloseAllEditorsOptions, OpenEditorInGroupContext } from 'vs/workbench/services/editor/common/editorGroupsService';
19+
import { IMoveEditorOptions, ICopyEditorOptions, ICloseEditorsFilter, IGroupChangeEvent, GroupChangeKind, GroupsOrder, ICloseEditorOptions, ICloseAllEditorsOptions, OpenEditorContext } from 'vs/workbench/services/editor/common/editorGroupsService';
2020
import { TabsTitleControl } from 'vs/workbench/browser/parts/editor/tabsTitleControl';
2121
import { EditorControl } from 'vs/workbench/browser/parts/editor/editorControl';
2222
import { IEditorProgressService } from 'vs/platform/progress/common/progress';
@@ -863,7 +863,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
863863

864864
//#region openEditor()
865865

866-
async openEditor(editor: EditorInput, options?: EditorOptions, context?: OpenEditorInGroupContext): Promise<IEditorPane | null> {
866+
async openEditor(editor: EditorInput, options?: EditorOptions, context?: OpenEditorContext): Promise<IEditorPane | null> {
867867

868868
// Guard against invalid inputs
869869
if (!editor) {
@@ -1171,7 +1171,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
11711171
}));
11721172

11731173
// A move to another group is an open first...
1174-
target.openEditor(editor, options, keepCopy ? OpenEditorInGroupContext.COPY_EDITOR : OpenEditorInGroupContext.MOVE_EDITOR);
1174+
target.openEditor(editor, options, keepCopy ? OpenEditorContext.COPY_EDITOR : OpenEditorContext.MOVE_EDITOR);
11751175

11761176
// ...and a close afterwards (unless we copy)
11771177
if (!keepCopy) {
@@ -1718,7 +1718,7 @@ class EditorOpeningEvent implements IEditorOpeningEvent {
17181718
private _group: GroupIdentifier,
17191719
private _editor: EditorInput,
17201720
private _options: EditorOptions | undefined,
1721-
private _context: OpenEditorInGroupContext | undefined
1721+
private _context: OpenEditorContext | undefined
17221722
) {
17231723
}
17241724

@@ -1734,7 +1734,7 @@ class EditorOpeningEvent implements IEditorOpeningEvent {
17341734
return this._options;
17351735
}
17361736

1737-
get context(): OpenEditorInGroupContext | undefined {
1737+
get context(): OpenEditorContext | undefined {
17381738
return this._context;
17391739
}
17401740

src/vs/workbench/contrib/files/browser/fileActions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import { sequence, timeout } from 'vs/base/common/async';
4848
import { IWorkingCopyFileService } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
4949
import { once } from 'vs/base/common/functional';
5050
import { IEditorOptions } from 'vs/platform/editor/common/editor';
51-
import { IEditorGroup, OpenEditorInGroupContext } from 'vs/workbench/services/editor/common/editorGroupsService';
51+
import { IEditorGroup, OpenEditorContext } from 'vs/workbench/services/editor/common/editorGroupsService';
5252
import { Codicon } from 'vs/base/common/codicons';
5353
import { IViewsService } from 'vs/workbench/common/views';
5454
import { openEditorWith, getAllAvailableEditors } from 'vs/workbench/contrib/files/common/openWith';
@@ -576,7 +576,7 @@ export class ToggleEditorTypeCommand extends Action {
576576
return;
577577
}
578578

579-
await firstNonActiveOverride[0].open(input, options, group, OpenEditorInGroupContext.NEW_EDITOR, firstNonActiveOverride[1].id)?.override;
579+
await firstNonActiveOverride[0].open(input, options, group, OpenEditorContext.NEW_EDITOR, firstNonActiveOverride[1].id)?.override;
580580
}
581581
}
582582

src/vs/workbench/contrib/files/common/openWith.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { IEditorInput, IEditorPane } from 'vs/workbench/common/editor';
1313
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
1414
import { DEFAULT_EDITOR_ID } from 'vs/workbench/contrib/files/common/files';
1515
import { CustomEditorAssociation, CustomEditorsAssociations, customEditorsAssociationsSettingId } from 'vs/workbench/services/editor/common/editorAssociationsSetting';
16-
import { IEditorGroup, OpenEditorInGroupContext } from 'vs/workbench/services/editor/common/editorGroupsService';
16+
import { IEditorGroup, OpenEditorContext } from 'vs/workbench/services/editor/common/editorGroupsService';
1717
import { IEditorService, IOpenEditorOverrideEntry, IOpenEditorOverrideHandler } from 'vs/workbench/services/editor/common/editorService';
1818

1919
const builtinProviderDisplayName = nls.localize('builtinProviderDisplayName', "Built-in");
@@ -45,7 +45,7 @@ export async function openEditorWith(
4545

4646
const overrideToUse = typeof id === 'string' && allEditorOverrides.find(([_, entry]) => entry.id === id);
4747
if (overrideToUse) {
48-
return overrideToUse[0].open(input, options, group, OpenEditorInGroupContext.NEW_EDITOR, id)?.override;
48+
return overrideToUse[0].open(input, options, group, OpenEditorContext.NEW_EDITOR, id)?.override;
4949
}
5050

5151
// Prompt
@@ -108,7 +108,7 @@ export async function openEditorWith(
108108
picker.show();
109109
});
110110

111-
return pickedItem?.handler.open(input!, options, group, OpenEditorInGroupContext.NEW_EDITOR, pickedItem.id)?.override;
111+
return pickedItem?.handler.open(input!, options, group, OpenEditorContext.NEW_EDITOR, pickedItem.id)?.override;
112112
}
113113

114114
export const defaultEditorOverrideEntry = Object.freeze({

src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookS
3030
import { NotebookService } from 'vs/workbench/contrib/notebook/browser/notebookServiceImpl';
3131
import { CellKind, CellUri } from 'vs/workbench/contrib/notebook/common/notebookCommon';
3232
import { NotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookProvider';
33-
import { IEditorGroup, OpenEditorInGroupContext } from 'vs/workbench/services/editor/common/editorGroupsService';
33+
import { IEditorGroup, OpenEditorContext } from 'vs/workbench/services/editor/common/editorGroupsService';
3434
import { IEditorService, IOpenEditorOverride } from 'vs/workbench/services/editor/common/editorService';
3535
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
3636
import { CustomEditorsAssociations, customEditorsAssociationsSettingId } from 'vs/workbench/services/editor/common/editorAssociationsSetting';
@@ -215,7 +215,7 @@ export class NotebookContribution extends Disposable implements IWorkbenchContri
215215
return this.notebookService.getContributedNotebookProviders(resource);
216216
}
217217

218-
private onEditorOpening(originalInput: IEditorInput, options: IEditorOptions | ITextEditorOptions | undefined, group: IEditorGroup, context: OpenEditorInGroupContext, id: string | undefined): IOpenEditorOverride | undefined {
218+
private onEditorOpening(originalInput: IEditorInput, options: IEditorOptions | ITextEditorOptions | undefined, group: IEditorGroup, context: OpenEditorContext, id: string | undefined): IOpenEditorOverride | undefined {
219219
if (originalInput instanceof NotebookEditorInput) {
220220
if ((originalInput.group === group.id || originalInput.group === undefined) && (originalInput.viewType === id || typeof id !== 'string')) {
221221
// No need to do anything
@@ -230,7 +230,7 @@ export class NotebookContribution extends Disposable implements IWorkbenchContri
230230
const copiedInput = this.instantiationService.createInstance(NotebookEditorInput, originalInput.resource, originalInput.name, originalInput.viewType);
231231
copiedInput.updateGroup(group.id);
232232

233-
if (context === OpenEditorInGroupContext.MOVE_EDITOR) {
233+
if (context === OpenEditorContext.MOVE_EDITOR) {
234234
// transfer ownership of editor widget
235235
const widgetRef = NotebookRegistry.getNotebookEditorWidget(originalInput);
236236
if (widgetRef) {

src/vs/workbench/services/editor/browser/editorService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { Event, Emitter } from 'vs/base/common/event';
1717
import { URI } from 'vs/base/common/uri';
1818
import { basename, isEqualOrParent, joinPath } from 'vs/base/common/resources';
1919
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
20-
import { IEditorGroupsService, IEditorGroup, GroupsOrder, IEditorReplacement, GroupChangeKind, preferredSideBySideGroupDirection, OpenEditorInGroupContext } from 'vs/workbench/services/editor/common/editorGroupsService';
20+
import { IEditorGroupsService, IEditorGroup, GroupsOrder, IEditorReplacement, GroupChangeKind, preferredSideBySideGroupDirection, OpenEditorContext } from 'vs/workbench/services/editor/common/editorGroupsService';
2121
import { IResourceEditorInputType, SIDE_GROUP, IResourceEditorReplacement, IOpenEditorOverrideHandler, IEditorService, SIDE_GROUP_TYPE, ACTIVE_GROUP_TYPE, ISaveEditorsOptions, ISaveAllEditorsOptions, IRevertAllEditorsOptions, IBaseSaveRevertAllEditorOptions, IOpenEditorOverrideEntry, ICustomEditorViewTypesHandler, ICustomEditorInfo } from 'vs/workbench/services/editor/common/editorService';
2222
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
2323
import { Disposable, IDisposable, dispose, toDisposable, DisposableStore } from 'vs/base/common/lifecycle';
@@ -501,7 +501,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
501501
}
502502

503503
for (const handler of this.openEditorHandlers) {
504-
const result = handler.open(event.editor, event.options, group, event.context || OpenEditorInGroupContext.NEW_EDITOR);
504+
const result = handler.open(event.editor, event.options, group, event.context || OpenEditorContext.NEW_EDITOR);
505505
const override = result?.override;
506506
if (override) {
507507
event.prevent((() => override.then(editor => withNullAsUndefined(editor))));

src/vs/workbench/services/editor/common/editorGroupsService.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,10 @@ export interface IGroupChangeEvent {
369369
editorIndex?: number;
370370
}
371371

372-
export const enum OpenEditorInGroupContext {
373-
NEW_EDITOR,
374-
MOVE_EDITOR,
375-
COPY_EDITOR
372+
export const enum OpenEditorContext {
373+
NEW_EDITOR = 1,
374+
MOVE_EDITOR = 2,
375+
COPY_EDITOR = 3
376376
}
377377

378378
export interface IEditorGroup {
@@ -469,7 +469,7 @@ export interface IEditorGroup {
469469
* @returns a promise that resolves around an IEditor instance unless
470470
* the call failed, or the editor was not opened as active editor.
471471
*/
472-
openEditor(editor: IEditorInput, options?: IEditorOptions | ITextEditorOptions, context?: OpenEditorInGroupContext): Promise<IEditorPane | null>;
472+
openEditor(editor: IEditorInput, options?: IEditorOptions | ITextEditorOptions, context?: OpenEditorContext): Promise<IEditorPane | null>;
473473

474474
/**
475475
* Opens editors in this group.

src/vs/workbench/services/editor/common/editorService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { IResourceEditorInput, IEditorOptions, ITextEditorOptions } from 'vs/pla
88
import { IEditorInput, IEditorPane, GroupIdentifier, IEditorInputWithOptions, IUntitledTextResourceEditorInput, IResourceDiffEditorInput, ITextEditorPane, ITextDiffEditorPane, IEditorIdentifier, ISaveOptions, IRevertOptions, EditorsOrder, IVisibleEditorPane } from 'vs/workbench/common/editor';
99
import { Event } from 'vs/base/common/event';
1010
import { IEditor, IDiffEditor } from 'vs/editor/common/editorCommon';
11-
import { IEditorGroup, IEditorReplacement, OpenEditorInGroupContext } from 'vs/workbench/services/editor/common/editorGroupsService';
11+
import { IEditorGroup, IEditorReplacement, OpenEditorContext } from 'vs/workbench/services/editor/common/editorGroupsService';
1212
import { IDisposable } from 'vs/base/common/lifecycle';
1313
import { URI } from 'vs/base/common/uri';
1414

@@ -35,7 +35,7 @@ export interface IOpenEditorOverrideEntry {
3535
}
3636

3737
export interface IOpenEditorOverrideHandler {
38-
open(editor: IEditorInput, options: IEditorOptions | ITextEditorOptions | undefined, group: IEditorGroup, context: OpenEditorInGroupContext, id?: string): IOpenEditorOverride | undefined;
38+
open(editor: IEditorInput, options: IEditorOptions | ITextEditorOptions | undefined, group: IEditorGroup, context: OpenEditorContext, id?: string): IOpenEditorOverride | undefined;
3939
getEditorOverrides?(resource: URI, options: IEditorOptions | undefined, group: IEditorGroup | undefined): IOpenEditorOverrideEntry[];
4040
}
4141

0 commit comments

Comments
 (0)