mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 18:19:12 +01:00
web - rename to window.confirmBeforeQuit and show in file menu for awareness
This commit is contained in:
@@ -284,8 +284,9 @@ registerAction2(ToggleScreencastModeAction);
|
||||
registerAction2(LogStorageAction);
|
||||
registerAction2(LogWorkingCopiesAction);
|
||||
|
||||
// --- Configuration
|
||||
|
||||
// Screencast Mode
|
||||
// Screen Cast Mode
|
||||
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
|
||||
configurationRegistry.registerConfiguration({
|
||||
id: 'screencastMode',
|
||||
|
||||
@@ -298,6 +298,8 @@ class GoHomeContributor implements IWorkbenchContribution {
|
||||
}
|
||||
}
|
||||
|
||||
// --- Actions Registration
|
||||
|
||||
const actionsRegistry = Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions);
|
||||
|
||||
actionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(NavigateUpAction, undefined), 'View: Navigate to the View Above', CATEGORIES.View.value);
|
||||
|
||||
@@ -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<IWorkbenchActionRegistry>(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<boolean>('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: {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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<boolean>('window.confirmBeforeQuit')) {
|
||||
console.warn('Unload prevented: window.confirmBeforeQuit=true');
|
||||
if (!this.signalExpectedShutdown && this.configurationService.getValue<boolean>('window.confirmBeforeClose')) {
|
||||
console.warn('Unload prevented: window.confirmBeforeClose=true');
|
||||
e.veto(true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user