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

fix some debt #211839

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions src/vs/platform/actions/common/menuService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class MenuInfo {
for (const group of this._menuGroups) {
const [id, items] = group;

const activeActions: Array<MenuItemAction | SubmenuItemAction> = [];
let activeActions: Array<MenuItemAction | SubmenuItemAction> | undefined;
for (const item of items) {
if (this._contextKeyService.contextMatchesRules(item.when)) {
const isMenuItem = isIMenuItem(item);
Expand All @@ -249,18 +249,18 @@ class MenuInfo {
if (isMenuItem) {
// MenuItemAction
const menuKeybinding = createConfigureKeybindingAction(item.command.id, item.when, this._commandService, this._keybindingService);
activeActions.push(new MenuItemAction(item.command, item.alt, options, menuHide, menuKeybinding, this._contextKeyService, this._commandService));
(activeActions ??= []).push(new MenuItemAction(item.command, item.alt, options, menuHide, menuKeybinding, this._contextKeyService, this._commandService));
} else {
// SubmenuItemAction
const groups = new MenuInfo(item.submenu, this._hiddenStates, this._collectContextKeysForSubmenus, this._commandService, this._keybindingService, this._contextKeyService).createActionGroups(options);
const submenuActions = Separator.join(...groups.map(g => g[1]));
if (submenuActions.length > 0) {
activeActions.push(new SubmenuItemAction(item, menuHide, submenuActions));
(activeActions ??= []).push(new SubmenuItemAction(item, menuHide, submenuActions));
}
}
}
}
if (activeActions.length > 0) {
if (activeActions && activeActions.length > 0) {
result.push([id, activeActions]);
}
}
Expand Down
52 changes: 26 additions & 26 deletions src/vs/workbench/browser/parts/editor/editorActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1965,7 +1965,7 @@ export class MoveEditorLeftInGroupAction extends ExecuteCommandAction {
},
f1: true,
category: Categories.View
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'left' } as ActiveEditorMoveCopyArguments);
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'left' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -1984,7 +1984,7 @@ export class MoveEditorRightInGroupAction extends ExecuteCommandAction {
},
f1: true,
category: Categories.View
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'right' } as ActiveEditorMoveCopyArguments);
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'right' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -2003,7 +2003,7 @@ export class MoveEditorToPreviousGroupAction extends ExecuteCommandAction {
},
f1: true,
category: Categories.View,
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'previous', by: 'group' } as ActiveEditorMoveCopyArguments);
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'previous', by: 'group' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -2022,7 +2022,7 @@ export class MoveEditorToNextGroupAction extends ExecuteCommandAction {
}
},
category: Categories.View
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'next', by: 'group' } as ActiveEditorMoveCopyArguments);
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'next', by: 'group' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -2034,7 +2034,7 @@ export class MoveEditorToAboveGroupAction extends ExecuteCommandAction {
title: localize2('moveEditorToAboveGroup', 'Move Editor into Group Above'),
f1: true,
category: Categories.View
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'up', by: 'group' } as ActiveEditorMoveCopyArguments);
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'up', by: 'group' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -2046,7 +2046,7 @@ export class MoveEditorToBelowGroupAction extends ExecuteCommandAction {
title: localize2('moveEditorToBelowGroup', 'Move Editor into Group Below'),
f1: true,
category: Categories.View
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'down', by: 'group' } as ActiveEditorMoveCopyArguments);
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'down', by: 'group' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -2058,7 +2058,7 @@ export class MoveEditorToLeftGroupAction extends ExecuteCommandAction {
title: localize2('moveEditorToLeftGroup', 'Move Editor into Left Group'),
f1: true,
category: Categories.View
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'left', by: 'group' } as ActiveEditorMoveCopyArguments);
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'left', by: 'group' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -2070,7 +2070,7 @@ export class MoveEditorToRightGroupAction extends ExecuteCommandAction {
title: localize2('moveEditorToRightGroup', 'Move Editor into Right Group'),
f1: true,
category: Categories.View
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'right', by: 'group' } as ActiveEditorMoveCopyArguments);
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'right', by: 'group' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -2089,7 +2089,7 @@ export class MoveEditorToFirstGroupAction extends ExecuteCommandAction {
}
},
category: Categories.View
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'first', by: 'group' } as ActiveEditorMoveCopyArguments);
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'first', by: 'group' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -2108,7 +2108,7 @@ export class MoveEditorToLastGroupAction extends ExecuteCommandAction {
}
},
category: Categories.View
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'last', by: 'group' } as ActiveEditorMoveCopyArguments);
}, MOVE_ACTIVE_EDITOR_COMMAND_ID, { to: 'last', by: 'group' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -2120,7 +2120,7 @@ export class SplitEditorToPreviousGroupAction extends ExecuteCommandAction {
title: localize2('splitEditorToPreviousGroup', 'Split Editor into Previous Group'),
f1: true,
category: Categories.View
}, COPY_ACTIVE_EDITOR_COMMAND_ID, { to: 'previous', by: 'group' } as ActiveEditorMoveCopyArguments);
}, COPY_ACTIVE_EDITOR_COMMAND_ID, { to: 'previous', by: 'group' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -2132,7 +2132,7 @@ export class SplitEditorToNextGroupAction extends ExecuteCommandAction {
title: localize2('splitEditorToNextGroup', 'Split Editor into Next Group'),
f1: true,
category: Categories.View
}, COPY_ACTIVE_EDITOR_COMMAND_ID, { to: 'next', by: 'group' } as ActiveEditorMoveCopyArguments);
}, COPY_ACTIVE_EDITOR_COMMAND_ID, { to: 'next', by: 'group' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -2144,7 +2144,7 @@ export class SplitEditorToAboveGroupAction extends ExecuteCommandAction {
title: localize2('splitEditorToAboveGroup', 'Split Editor into Group Above'),
f1: true,
category: Categories.View
}, COPY_ACTIVE_EDITOR_COMMAND_ID, { to: 'up', by: 'group' } as ActiveEditorMoveCopyArguments);
}, COPY_ACTIVE_EDITOR_COMMAND_ID, { to: 'up', by: 'group' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -2156,7 +2156,7 @@ export class SplitEditorToBelowGroupAction extends ExecuteCommandAction {
title: localize2('splitEditorToBelowGroup', 'Split Editor into Group Below'),
f1: true,
category: Categories.View
}, COPY_ACTIVE_EDITOR_COMMAND_ID, { to: 'down', by: 'group' } as ActiveEditorMoveCopyArguments);
}, COPY_ACTIVE_EDITOR_COMMAND_ID, { to: 'down', by: 'group' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -2171,7 +2171,7 @@ export class SplitEditorToLeftGroupAction extends ExecuteCommandAction {
title: localize2('splitEditorToLeftGroup', "Split Editor into Left Group"),
f1: true,
category: Categories.View
}, COPY_ACTIVE_EDITOR_COMMAND_ID, { to: 'left', by: 'group' } as ActiveEditorMoveCopyArguments);
}, COPY_ACTIVE_EDITOR_COMMAND_ID, { to: 'left', by: 'group' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -2183,7 +2183,7 @@ export class SplitEditorToRightGroupAction extends ExecuteCommandAction {
title: localize2('splitEditorToRightGroup', 'Split Editor into Right Group'),
f1: true,
category: Categories.View
}, COPY_ACTIVE_EDITOR_COMMAND_ID, { to: 'right', by: 'group' } as ActiveEditorMoveCopyArguments);
}, COPY_ACTIVE_EDITOR_COMMAND_ID, { to: 'right', by: 'group' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -2195,7 +2195,7 @@ export class SplitEditorToFirstGroupAction extends ExecuteCommandAction {
title: localize2('splitEditorToFirstGroup', 'Split Editor into First Group'),
f1: true,
category: Categories.View
}, COPY_ACTIVE_EDITOR_COMMAND_ID, { to: 'first', by: 'group' } as ActiveEditorMoveCopyArguments);
}, COPY_ACTIVE_EDITOR_COMMAND_ID, { to: 'first', by: 'group' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -2207,7 +2207,7 @@ export class SplitEditorToLastGroupAction extends ExecuteCommandAction {
title: localize2('splitEditorToLastGroup', 'Split Editor into Last Group'),
f1: true,
category: Categories.View
}, COPY_ACTIVE_EDITOR_COMMAND_ID, { to: 'last', by: 'group' } as ActiveEditorMoveCopyArguments);
}, COPY_ACTIVE_EDITOR_COMMAND_ID, { to: 'last', by: 'group' } satisfies ActiveEditorMoveCopyArguments);
}
}

Expand All @@ -2221,7 +2221,7 @@ export class EditorLayoutSingleAction extends ExecuteCommandAction {
title: localize2('editorLayoutSingle', 'Single Column Editor Layout'),
f1: true,
category: Categories.View
}, LAYOUT_EDITOR_GROUPS_COMMAND_ID, { groups: [{}] } as EditorGroupLayout);
}, LAYOUT_EDITOR_GROUPS_COMMAND_ID, { groups: [{}], orientation: GroupOrientation.HORIZONTAL } satisfies EditorGroupLayout);
}
}

Expand All @@ -2235,7 +2235,7 @@ export class EditorLayoutTwoColumnsAction extends ExecuteCommandAction {
title: localize2('editorLayoutTwoColumns', 'Two Columns Editor Layout'),
f1: true,
category: Categories.View
}, LAYOUT_EDITOR_GROUPS_COMMAND_ID, { groups: [{}, {}], orientation: GroupOrientation.HORIZONTAL } as EditorGroupLayout);
}, LAYOUT_EDITOR_GROUPS_COMMAND_ID, { groups: [{}, {}], orientation: GroupOrientation.HORIZONTAL } satisfies EditorGroupLayout);
}
}

Expand All @@ -2249,7 +2249,7 @@ export class EditorLayoutThreeColumnsAction extends ExecuteCommandAction {
title: localize2('editorLayoutThreeColumns', 'Three Columns Editor Layout'),
f1: true,
category: Categories.View
}, LAYOUT_EDITOR_GROUPS_COMMAND_ID, { groups: [{}, {}, {}], orientation: GroupOrientation.HORIZONTAL } as EditorGroupLayout);
}, LAYOUT_EDITOR_GROUPS_COMMAND_ID, { groups: [{}, {}, {}], orientation: GroupOrientation.HORIZONTAL } satisfies EditorGroupLayout);
}
}

Expand All @@ -2263,7 +2263,7 @@ export class EditorLayoutTwoRowsAction extends ExecuteCommandAction {
title: localize2('editorLayoutTwoRows', 'Two Rows Editor Layout'),
f1: true,
category: Categories.View
}, LAYOUT_EDITOR_GROUPS_COMMAND_ID, { groups: [{}, {}], orientation: GroupOrientation.VERTICAL } as EditorGroupLayout);
}, LAYOUT_EDITOR_GROUPS_COMMAND_ID, { groups: [{}, {}], orientation: GroupOrientation.VERTICAL } satisfies EditorGroupLayout);
}
}

Expand All @@ -2277,7 +2277,7 @@ export class EditorLayoutThreeRowsAction extends ExecuteCommandAction {
title: localize2('editorLayoutThreeRows', 'Three Rows Editor Layout'),
f1: true,
category: Categories.View
}, LAYOUT_EDITOR_GROUPS_COMMAND_ID, { groups: [{}, {}, {}], orientation: GroupOrientation.VERTICAL } as EditorGroupLayout);
}, LAYOUT_EDITOR_GROUPS_COMMAND_ID, { groups: [{}, {}, {}], orientation: GroupOrientation.VERTICAL } satisfies EditorGroupLayout);
}
}

Expand All @@ -2291,7 +2291,7 @@ export class EditorLayoutTwoByTwoGridAction extends ExecuteCommandAction {
title: localize2('editorLayoutTwoByTwoGrid', 'Grid Editor Layout (2x2)'),
f1: true,
category: Categories.View
}, LAYOUT_EDITOR_GROUPS_COMMAND_ID, { groups: [{ groups: [{}, {}] }, { groups: [{}, {}] }] } as EditorGroupLayout);
}, LAYOUT_EDITOR_GROUPS_COMMAND_ID, { groups: [{ groups: [{}, {}] }, { groups: [{}, {}] }], orientation: GroupOrientation.HORIZONTAL } satisfies EditorGroupLayout);
}
}

Expand All @@ -2305,7 +2305,7 @@ export class EditorLayoutTwoColumnsBottomAction extends ExecuteCommandAction {
title: localize2('editorLayoutTwoColumnsBottom', 'Two Columns Bottom Editor Layout'),
f1: true,
category: Categories.View
}, LAYOUT_EDITOR_GROUPS_COMMAND_ID, { groups: [{}, { groups: [{}, {}] }], orientation: GroupOrientation.VERTICAL } as EditorGroupLayout);
}, LAYOUT_EDITOR_GROUPS_COMMAND_ID, { groups: [{}, { groups: [{}, {}] }], orientation: GroupOrientation.VERTICAL } satisfies EditorGroupLayout);
}
}

Expand All @@ -2319,7 +2319,7 @@ export class EditorLayoutTwoRowsRightAction extends ExecuteCommandAction {
title: localize2('editorLayoutTwoRowsRight', 'Two Rows Right Editor Layout'),
f1: true,
category: Categories.View
}, LAYOUT_EDITOR_GROUPS_COMMAND_ID, { groups: [{}, { groups: [{}, {}] }], orientation: GroupOrientation.HORIZONTAL } as EditorGroupLayout);
}, LAYOUT_EDITOR_GROUPS_COMMAND_ID, { groups: [{}, { groups: [{}, {}] }], orientation: GroupOrientation.HORIZONTAL } satisfies EditorGroupLayout);
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/vs/workbench/browser/parts/editor/editorCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ export const EDITOR_CORE_NAVIGATION_COMMANDS = [
];

export interface ActiveEditorMoveCopyArguments {
to: 'first' | 'last' | 'left' | 'right' | 'up' | 'down' | 'center' | 'position' | 'previous' | 'next';
by: 'tab' | 'group';
value: number;
to?: 'first' | 'last' | 'left' | 'right' | 'up' | 'down' | 'center' | 'position' | 'previous' | 'next';
by?: 'tab' | 'group';
value?: number;
}

const isActiveEditorMoveCopyArg = function (arg: ActiveEditorMoveCopyArguments): boolean {
Expand Down Expand Up @@ -224,16 +224,16 @@ function registerActiveEditorMoveCopyCommand(): void {
index = group.count - 1;
break;
case 'left':
index = index - args.value;
index = index - (args.value ?? 1);
break;
case 'right':
index = index + args.value;
index = index + (args.value ?? 1);
break;
case 'center':
index = Math.round(group.count / 2) - 1;
break;
case 'position':
index = args.value - 1;
index = (args.value ?? 1) - 1;
break;
}

Expand Down Expand Up @@ -292,7 +292,7 @@ function registerActiveEditorMoveCopyCommand(): void {
targetGroup = editorGroupService.getGroups(GroupsOrder.GRID_APPEARANCE)[(editorGroupService.count / 2) - 1];
break;
case 'position':
targetGroup = editorGroupService.getGroups(GroupsOrder.GRID_APPEARANCE)[args.value - 1];
targetGroup = editorGroupService.getGroups(GroupsOrder.GRID_APPEARANCE)[(args.value ?? 1) - 1];
break;
}

Expand Down
14 changes: 7 additions & 7 deletions src/vs/workbench/browser/parts/paneCompositeBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,26 +578,26 @@ export class PaneCompositeBar extends Disposable {

private storeCachedViewContainersState(cachedViewContainers: ICachedViewContainer[]): void {
const pinnedViewContainers = this.getPinnedViewContainers();
this.setPinnedViewContainers(cachedViewContainers.map(({ id, pinned, order }) => (<IPinnedViewContainer>{
this.setPinnedViewContainers(cachedViewContainers.map(({ id, pinned, order }) => ({
id,
pinned,
visible: pinnedViewContainers.find(({ id: pinnedId }) => pinnedId === id)?.visible,
visible: Boolean(pinnedViewContainers.find(({ id: pinnedId }) => pinnedId === id)?.visible),
order
})));
} satisfies IPinnedViewContainer)));

this.setPlaceholderViewContainers(cachedViewContainers.map(({ id, icon, name, views, isBuiltin }) => (<IPlaceholderViewContainer>{
this.setPlaceholderViewContainers(cachedViewContainers.map(({ id, icon, name, views, isBuiltin }) => ({
id,
iconUrl: URI.isUri(icon) ? icon : undefined,
themeIcon: ThemeIcon.isThemeIcon(icon) ? icon : undefined,
name,
isBuiltin,
views
})));
} satisfies IPlaceholderViewContainer)));

this.setViewContainersWorkspaceState(cachedViewContainers.map(({ id, visible }) => (<IViewContainerWorkspaceState>{
this.setViewContainersWorkspaceState(cachedViewContainers.map(({ id, visible }) => ({
id,
visible,
})));
} satisfies IViewContainerWorkspaceState)));
}

private getPinnedViewContainers(): IPinnedViewContainer[] {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/views/viewPaneContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ import { IWorkbenchLayoutService, LayoutSettings, Position } from 'vs/workbench/
import { IBaseActionViewItemOptions } from 'vs/base/browser/ui/actionbar/actionViewItems';

export const ViewsSubMenu = new MenuId('Views');
MenuRegistry.appendMenuItem(MenuId.ViewContainerTitle, <ISubmenuItem>{
MenuRegistry.appendMenuItem(MenuId.ViewContainerTitle, {
submenu: ViewsSubMenu,
title: nls.localize('views', "Views"),
order: 1,
});
} satisfies ISubmenuItem);

export interface IViewPaneContainerOptions extends IPaneViewOptions {
mergeViewWithContainerWhenSingleView: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/web.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class BrowserMain extends Disposable {

let logger: DelayedLogChannel | undefined = undefined;

return <IWorkbench>{
return {
commands: {
executeCommand: (command, ...args) => commandService.executeCommand(command, ...args)
},
Expand Down Expand Up @@ -248,7 +248,7 @@ export class BrowserMain extends Disposable {
}
},
shutdown: () => lifecycleService.shutdown()
};
} satisfies IWorkbench;
});
}

Expand Down
3 changes: 1 addition & 2 deletions src/vs/workbench/common/contextkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,12 @@ export function applyAvailableEditorIds(contextKey: IContextKey<string>, editor:
}

const editorResource = editor.resource;
const editors = editorResource ? editorResolverService.getEditors(editorResource).map(editor => editor.id) : [];

if (editorResource?.scheme === Schemas.untitled && editor.editorId !== DEFAULT_EDITOR_ASSOCIATION.id) {
// Non text editor untitled files cannot be easily serialized between extensions
// so instead we disable this context key to prevent common commands that act on the active editor
contextKey.set('');
} else {
const editors = editorResource ? editorResolverService.getEditors(editorResource).map(editor => editor.id) : [];
contextKey.set(editors.join(','));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class WorkspacesFinderContribution extends Disposable implements IWorkben
label: localize('selectWorkspace', "Select Workspace"),
run: () => {
this.quickInputService.pick(
workspaces.map(workspace => ({ label: workspace } as IQuickPickItem)),
workspaces.map(workspace => ({ label: workspace } satisfies IQuickPickItem)),
{ placeHolder: localize('selectToOpen', "Select a workspace to open") }).then(pick => {
if (pick) {
this.hostService.openWindow([{ workspaceUri: joinPath(folder, pick.label) }]);
Expand Down
Loading