diff --git a/src/vs/workbench/browser/actions/developerActions.ts b/src/vs/workbench/browser/actions/developerActions.ts index 97c3bdb4838..9eb0d3ea714 100644 --- a/src/vs/workbench/browser/actions/developerActions.ts +++ b/src/vs/workbench/browser/actions/developerActions.ts @@ -284,8 +284,9 @@ registerAction2(ToggleScreencastModeAction); registerAction2(LogStorageAction); registerAction2(LogWorkingCopiesAction); +// --- Configuration -// Screencast Mode +// Screen Cast Mode const configurationRegistry = Registry.as(ConfigurationExtensions.Configuration); configurationRegistry.registerConfiguration({ id: 'screencastMode', diff --git a/src/vs/workbench/browser/actions/navigationActions.ts b/src/vs/workbench/browser/actions/navigationActions.ts index a53bd1e9a88..b9198a1e02f 100644 --- a/src/vs/workbench/browser/actions/navigationActions.ts +++ b/src/vs/workbench/browser/actions/navigationActions.ts @@ -298,6 +298,8 @@ class GoHomeContributor implements IWorkbenchContribution { } } +// --- Actions Registration + const actionsRegistry = Registry.as(Extensions.WorkbenchActions); actionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(NavigateUpAction, undefined), 'View: Navigate to the View Above', CATEGORIES.View.value); diff --git a/src/vs/workbench/browser/actions/windowActions.ts b/src/vs/workbench/browser/actions/windowActions.ts index a91096687ae..1115d77f027 100644 --- a/src/vs/workbench/browser/actions/windowActions.ts +++ b/src/vs/workbench/browser/actions/windowActions.ts @@ -32,6 +32,8 @@ import { IHostService } from 'vs/workbench/services/host/browser/host'; import { ResourceMap } from 'vs/base/common/map'; import { Codicon } from 'vs/base/common/codicons'; import { isHTMLElement } from 'vs/base/browser/dom'; +import { CommandsRegistry } from 'vs/platform/commands/common/commands'; +import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration'; export const inRecentFilesPickerContextKey = 'inRecentFilesPicker'; @@ -333,6 +335,24 @@ export class NewWindowAction extends Action { } } +class BlurAction extends Action2 { + + constructor() { + super({ + id: 'workbench.action.blur', + title: nls.localize('blur', "Remove keyboard focus from focused element") + }); + } + + run(): void { + const el = document.activeElement; + + if (isHTMLElement(el)) { + el.blur(); + } + } +} + const registry = Registry.as(Extensions.WorkbenchActions); // --- Actions Registration @@ -348,6 +368,8 @@ registry.registerWorkbenchAction(SyncActionDescriptor.from(ReloadWindowAction), registry.registerWorkbenchAction(SyncActionDescriptor.from(ShowAboutDialogAction), `Help: About`, CATEGORIES.Help.value); +registerAction2(BlurAction); + // --- Commands/Keybindings Registration const recentFilesPickerContext = ContextKeyExpr.and(inQuickPickContext, ContextKeyExpr.has(inRecentFilesPickerContextKey)); @@ -372,26 +394,6 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.KEY_R } }); -class BlurAction extends Action2 { - - constructor() { - super({ - id: 'workbench.action.blur', - title: nls.localize('blur', "Remove keyboard focus from focused element") - }); - } - - run(): void { - const el = document.activeElement; - - if (isHTMLElement(el)) { - el.blur(); - } - } -} - -registerAction2(BlurAction); - KeybindingsRegistry.registerKeybindingRule({ id: ReloadWindowAction.ID, weight: KeybindingWeight.WorkbenchContrib + 50, @@ -399,8 +401,26 @@ KeybindingsRegistry.registerKeybindingRule({ primary: KeyMod.CtrlCmd | KeyCode.KEY_R }); +CommandsRegistry.registerCommand('workbench.action.toggleConfirmBeforeClose', accessor => { + const configurationService = accessor.get(IConfigurationService); + const setting = configurationService.inspect('window.confirmBeforeClose').userValue; + + return configurationService.updateValue('window.confirmBeforeClose', setting === false ? true : false, ConfigurationTarget.USER); +}); + // --- Menu Registration +MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, { + group: 'z_ConfirmClose', + command: { + id: 'workbench.action.toggleConfirmBeforeClose', + title: nls.localize('miConfirmClose', "Confirm Before Close"), + toggled: ContextKeyExpr.equals('config.window.confirmBeforeClose', true) + }, + order: 1, + when: IsWebContext +}); + MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, { group: '1_new', command: { diff --git a/src/vs/workbench/browser/workbench.contribution.ts b/src/vs/workbench/browser/workbench.contribution.ts index ac34be15cd5..c28dada37fb 100644 --- a/src/vs/workbench/browser/workbench.contribution.ts +++ b/src/vs/workbench/browser/workbench.contribution.ts @@ -403,10 +403,10 @@ import { isStandalone } from 'vs/base/browser/browser'; 'scope': ConfigurationScope.APPLICATION, 'markdownDescription': nls.localize('openFoldersInNewWindow', "Controls whether folders should open in a new window or replace the last active window.\nNote that there can still be cases where this setting is ignored (e.g. when using the `--new-window` or `--reuse-window` command line option).") }, - 'window.confirmBeforeQuit': { + 'window.confirmBeforeClose': { 'type': 'boolean', 'default': isWeb && !isStandalone, // on by default in web, unless PWA - 'description': nls.localize('confirmBeforeQuitWeb', "Controls whether to ask for confirmation before closing the browser tab or window."), + 'description': nls.localize('confirmBeforeCloseWeb', "Controls whether to ask for confirmation before closing the browser tab or window."), 'scope': ConfigurationScope.APPLICATION, 'included': isWeb } diff --git a/src/vs/workbench/services/host/browser/browserHostService.ts b/src/vs/workbench/services/host/browser/browserHostService.ts index c3e626fe751..dea4121181d 100644 --- a/src/vs/workbench/services/host/browser/browserHostService.ts +++ b/src/vs/workbench/services/host/browser/browserHostService.ts @@ -98,8 +98,8 @@ export class BrowserHostService extends Disposable implements IHostService { // Veto is setting is configured as such and we are not // expecting a navigation that was triggered by the user - if (!this.signalExpectedShutdown && this.configurationService.getValue('window.confirmBeforeQuit')) { - console.warn('Unload prevented: window.confirmBeforeQuit=true'); + if (!this.signalExpectedShutdown && this.configurationService.getValue('window.confirmBeforeClose')) { + console.warn('Unload prevented: window.confirmBeforeClose=true'); e.veto(true); }