diff --git a/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStarted.contribution.ts b/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStarted.contribution.ts index 45c1b9e55af..bd80f2e53ae 100644 --- a/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStarted.contribution.ts +++ b/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStarted.contribution.ts @@ -15,7 +15,7 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { EditorDescriptor, IEditorRegistry } from 'vs/workbench/browser/editor'; import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; -import { IGettingStartedNewMenuEntryDescriptorCategory, IGettingStartedService } from 'vs/workbench/contrib/welcome/gettingStarted/browser/gettingStartedService'; +import { HasMultipleNewFileEntries, IGettingStartedNewMenuEntryDescriptorCategory, IGettingStartedService } from 'vs/workbench/contrib/welcome/gettingStarted/browser/gettingStartedService'; import { GettingStartedInput } from 'vs/workbench/contrib/welcome/gettingStarted/browser/gettingStartedInput'; import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions'; import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; @@ -199,6 +199,7 @@ registerAction2(class extends Action2 { }, menu: { id: MenuId.MenubarFileMenu, + when: HasMultipleNewFileEntries, group: '1_new', order: 3 } diff --git a/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStartedService.ts b/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStartedService.ts index c74ad120827..f6bdff48359 100644 --- a/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStartedService.ts +++ b/src/vs/workbench/contrib/welcome/gettingStarted/browser/gettingStartedService.ts @@ -36,6 +36,7 @@ import { IQuickInputService, IQuickPickItem, IQuickPickSeparator } from 'vs/plat import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; export const WorkspacePlatform = new RawContextKey<'mac' | 'linux' | 'windows' | undefined>('workspacePlatform', undefined, localize('workspacePlatform', "The platform of the current workspace, which in remote contexts may be different from the platform of the UI")); +export const HasMultipleNewFileEntries = new RawContextKey('hasMultipleNewFileEntries', false); export const IGettingStartedService = createDecorator('gettingStartedService'); @@ -309,6 +310,8 @@ export class GettingStartedService extends Disposable implements IGettingStarted e.affectedKeys.forEach(key => { this.progressByEvent('onSettingChanged:' + key); }); })); + HasMultipleNewFileEntries.bindTo(this.contextService).set(false); + this.remoteAgentService.getEnvironment().then(env => { const remoteOS = env?.os; @@ -672,6 +675,10 @@ export class GettingStartedService extends Disposable implements IGettingStarted private registerNewMenuItem(categoryDescriptor: IGettingStartedNewMenuEntryDescriptor) { this.newMenuItems.push(categoryDescriptor); this.newMenuItems.sort((a, b) => b.category - a.category); + if (categoryDescriptor.category === IGettingStartedNewMenuEntryDescriptorCategory.file || categoryDescriptor.category === IGettingStartedNewMenuEntryDescriptorCategory.notebook) { + HasMultipleNewFileEntries.bindTo(this.contextService).set(true); + } + this._onDidAddNewEntry.fire(); } @@ -697,6 +704,11 @@ export class GettingStartedService extends Disposable implements IGettingStarted } this.newMenuItems = this.newMenuItems.filter(entry => entry.sourceExtensionId !== extension.identifier.value); + HasMultipleNewFileEntries.bindTo(this.contextService).set( + this.newMenuItems.filter(entry => + entry.category === IGettingStartedNewMenuEntryDescriptorCategory.file + || entry.category === IGettingStartedNewMenuEntryDescriptorCategory.notebook).length > 1 + ); } private registerDoneListeners(step: IGettingStartedStep) {