Merge from vscode 52dcb723a39ae75bee1bd56b3312d7fcdc87aeed (#6719)

This commit is contained in:
Anthony Dresser
2019-08-12 21:31:51 -07:00
committed by GitHub
parent 00250839fc
commit 7eba8c4c03
616 changed files with 9472 additions and 7087 deletions

View File

@@ -15,7 +15,6 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IQuickInputService, IQuickInputButton } from 'vs/platform/quickinput/common/quickInput';
import { getIconClasses } from 'vs/editor/common/services/getIconClasses';
import product from 'vs/platform/product/node/product';
import { ICommandHandler } from 'vs/platform/commands/common/commands';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -55,8 +54,12 @@ export class NewWindowAction extends Action {
}
export abstract class BaseZoomAction extends Action {
private static readonly SETTING_KEY = 'window.zoomLevel';
private static readonly MAX_ZOOM_LEVEL = 9;
private static readonly MIN_ZOOM_LEVEL = -8;
constructor(
id: string,
label: string,
@@ -68,6 +71,10 @@ export abstract class BaseZoomAction extends Action {
protected async setConfiguredZoomLevel(level: number): Promise<void> {
level = Math.round(level); // when reaching smallest zoom, prevent fractional zoom levels
if (level > BaseZoomAction.MAX_ZOOM_LEVEL || level < BaseZoomAction.MIN_ZOOM_LEVEL) {
return; // https://github.com/microsoft/vscode/issues/48357
}
const applyZoom = () => {
webFrame.setZoomLevel(level);
browser.setZoomFactor(webFrame.getZoomFactor());
@@ -267,25 +274,6 @@ export class QuickSwitchWindow extends BaseSwitchWindow {
}
}
export class ShowAboutDialogAction extends Action {
static readonly ID = 'workbench.action.showAboutDialog';
static LABEL = nls.localize('about', "About {0}", product.applicationName);
constructor(
id: string,
label: string,
@IWindowsService private readonly windowsService: IWindowsService
) {
super(id, label);
}
run(): Promise<void> {
return this.windowsService.openAboutDialog();
}
}
export const NewWindowTabHandler: ICommandHandler = function (accessor: ServicesAccessor) {
return accessor.get(IWindowsService).newWindowTab();
};

View File

@@ -13,17 +13,16 @@ import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
import { isWindows, isLinux, isMacintosh } from 'vs/base/common/platform';
import { KeybindingsReferenceAction, OpenDocumentationUrlAction, OpenIntroductoryVideosUrlAction, OpenTipsAndTricksUrlAction, OpenTwitterUrlAction, OpenRequestFeatureUrlAction, OpenPrivacyStatementUrlAction, OpenLicenseUrlAction, OpenNewsletterSignupUrlAction } from 'vs/workbench/electron-browser/actions/helpActions';
import { ToggleSharedProcessAction, ToggleDevToolsAction } from 'vs/workbench/electron-browser/actions/developerActions';
import { ShowAboutDialogAction, ZoomResetAction, ZoomOutAction, ZoomInAction, CloseCurrentWindowAction, SwitchWindow, NewWindowAction, QuickSwitchWindow, ReloadWindowWithExtensionsDisabledAction, NewWindowTabHandler, ShowPreviousWindowTabHandler, ShowNextWindowTabHandler, MoveWindowTabToNewWindowHandler, MergeWindowTabsHandlerHandler, ToggleWindowTabsBarHandler } from 'vs/workbench/electron-browser/actions/windowActions';
import { AddRootFolderAction, GlobalRemoveRootFolderAction, SaveWorkspaceAsAction, OpenWorkspaceConfigFileAction, DuplicateWorkspaceInNewWindowAction, CloseWorkspaceAction } from 'vs/workbench/browser/actions/workspaceActions';
import { ZoomResetAction, ZoomOutAction, ZoomInAction, CloseCurrentWindowAction, SwitchWindow, NewWindowAction, QuickSwitchWindow, ReloadWindowWithExtensionsDisabledAction, NewWindowTabHandler, ShowPreviousWindowTabHandler, ShowNextWindowTabHandler, MoveWindowTabToNewWindowHandler, MergeWindowTabsHandlerHandler, ToggleWindowTabsBarHandler } from 'vs/workbench/electron-browser/actions/windowActions';
import { AddRootFolderAction, GlobalRemoveRootFolderAction, SaveWorkspaceAsAction, DuplicateWorkspaceInNewWindowAction, CloseWorkspaceAction } from 'vs/workbench/browser/actions/workspaceActions';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ADD_ROOT_FOLDER_COMMAND_ID } from 'vs/workbench/browser/actions/workspaceCommands';
import { SupportsWorkspacesContext, IsMacContext, HasMacNativeTabsContext, IsDevelopmentContext, WorkbenchStateContext, WorkspaceFolderCountContext } from 'vs/workbench/browser/contextkeys';
import { NoEditorsVisibleContext, SingleEditorGroupsContext } from 'vs/workbench/common/editor';
import { IWindowService, IWindowsService } from 'vs/platform/windows/common/windows';
import product from 'vs/platform/product/node/product';
import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions'; // {{SQL CARBON EDIT}} add import
@@ -55,7 +54,7 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
registry.registerWorkbenchAction(new SyncActionDescriptor(QuickSwitchWindow, QuickSwitchWindow.ID, QuickSwitchWindow.LABEL), 'Quick Switch Window...');
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'workbench.action.closeWindow', // close the window when the last editor is closed by reusing the same keybinding
id: CloseCurrentWindowAction.ID, // close the window when the last editor is closed by reusing the same keybinding
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(NoEditorsVisibleContext, SingleEditorGroupsContext),
primary: KeyMod.CtrlCmd | KeyCode.KEY_W,
@@ -86,18 +85,6 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
registry.registerWorkbenchAction(new SyncActionDescriptor(GlobalRemoveRootFolderAction, GlobalRemoveRootFolderAction.ID, GlobalRemoveRootFolderAction.LABEL), 'Workspaces: Remove Folder from Workspace...', workspacesCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(SaveWorkspaceAsAction, SaveWorkspaceAsAction.ID, SaveWorkspaceAsAction.LABEL), 'Workspaces: Save Workspace As...', workspacesCategory, SupportsWorkspacesContext);
registry.registerWorkbenchAction(new SyncActionDescriptor(DuplicateWorkspaceInNewWindowAction, DuplicateWorkspaceInNewWindowAction.ID, DuplicateWorkspaceInNewWindowAction.LABEL), 'Workspaces: Duplicate Workspace in New Window', workspacesCategory);
CommandsRegistry.registerCommand(OpenWorkspaceConfigFileAction.ID, serviceAccessor => {
serviceAccessor.get(IInstantiationService).createInstance(OpenWorkspaceConfigFileAction, OpenWorkspaceConfigFileAction.ID, OpenWorkspaceConfigFileAction.LABEL).run();
});
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
command: {
id: OpenWorkspaceConfigFileAction.ID,
title: { value: `${workspacesCategory}: ${OpenWorkspaceConfigFileAction.LABEL}`, original: 'Workspaces: Open Workspace Configuration File' },
},
when: WorkbenchStateContext.isEqualTo('workspace')
});
})();
// Actions: macOS Native Tabs
@@ -165,7 +152,6 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenRequestFeatureUrlAction, OpenRequestFeatureUrlAction.ID, OpenRequestFeatureUrlAction.LABEL), 'Help: Search Feature Requests', helpCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenLicenseUrlAction, OpenLicenseUrlAction.ID, OpenLicenseUrlAction.LABEL), 'Help: View License', helpCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenPrivacyStatementUrlAction, OpenPrivacyStatementUrlAction.ID, OpenPrivacyStatementUrlAction.LABEL), 'Help: Privacy Statement', helpCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowAboutDialogAction, ShowAboutDialogAction.ID, ShowAboutDialogAction.LABEL), `Help: About ${product.applicationName}`, helpCategory);
})();
})();
@@ -283,7 +269,7 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, {
group: '1_welcome',
command: {
id: 'workbench.action.openDocumentationUrl',
id: OpenDocumentationUrlAction.ID,
title: nls.localize({ key: 'miDocumentation', comment: ['&& denotes a mnemonic'] }, "&&Documentation")
},
order: 3
@@ -303,7 +289,7 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, {
group: '2_reference',
command: {
id: 'workbench.action.keybindingsReference',
id: KeybindingsReferenceAction.ID,
title: nls.localize({ key: 'miKeyboardShortcuts', comment: ['&& denotes a mnemonic'] }, "&&Keyboard Shortcuts Reference")
},
order: 1
@@ -312,7 +298,7 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, {
group: '2_reference',
command: {
id: 'workbench.action.openIntroductoryVideosUrl',
id: OpenIntroductoryVideosUrlAction.ID,
title: nls.localize({ key: 'miIntroductoryVideos', comment: ['&& denotes a mnemonic'] }, "Introductory &&Videos")
},
order: 2
@@ -321,7 +307,7 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, {
group: '2_reference',
command: {
id: 'workbench.action.openTipsAndTricksUrl',
id: OpenTipsAndTricksUrlAction.ID,
title: nls.localize({ key: 'miTipsAndTricks', comment: ['&& denotes a mnemonic'] }, "Tips and Tri&&cks")
},
order: 3
@@ -331,7 +317,7 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, {
group: '3_feedback',
command: {
id: 'workbench.action.openTwitterUrl',
id: OpenTwitterUrlAction.ID,
title: nls.localize({ key: 'miTwitter', comment: ['&& denotes a mnemonic'] }, "&&Join Us on Twitter")
},
order: 1
@@ -340,7 +326,7 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, {
group: '3_feedback',
command: {
id: 'workbench.action.openRequestFeatureUrl',
id: OpenRequestFeatureUrlAction.ID,
title: nls.localize({ key: 'miUserVoice', comment: ['&& denotes a mnemonic'] }, "&&Search Feature Requests")
},
order: 2
@@ -360,7 +346,7 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, {
group: '4_legal',
command: {
id: 'workbench.action.openLicenseUrl',
id: OpenLicenseUrlAction.ID,
title: nls.localize({ key: 'miLicense', comment: ['&& denotes a mnemonic'] }, "View &&License")
},
order: 1
@@ -369,7 +355,7 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, {
group: '4_legal',
command: {
id: 'workbench.action.openPrivacyStatementUrl',
id: OpenPrivacyStatementUrlAction.ID,
title: nls.localize({ key: 'miPrivacyStatement', comment: ['&& denotes a mnemonic'] }, "Privac&&y Statement")
},
order: 2
@@ -379,7 +365,7 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, {
group: '5_tools',
command: {
id: 'workbench.action.toggleDevTools',
id: ToggleDevToolsAction.ID,
title: nls.localize({ key: 'miToggleDevTools', comment: ['&& denotes a mnemonic'] }, "&&Toggle Developer Tools")
},
order: 1
@@ -393,17 +379,6 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
},
order: 2
});
// About
MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, {
group: 'z_about',
command: {
id: 'workbench.action.showAboutDialog',
title: nls.localize({ key: 'miAbout', comment: ['&& denotes a mnemonic'] }, "&&About")
},
order: 1,
when: IsMacContext.toNegated()
});
})();
// Configuration
@@ -519,7 +494,7 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
'default': true,
'description': nls.localize('window.nativeFullScreen', "Controls if native full-screen should be used on macOS. Disable this option to prevent macOS from creating a new space when going full-screen."),
'scope': ConfigurationScope.APPLICATION,
'included': false /* isMacintosh */
'included': isMacintosh
},
'window.clickThroughInactive': {
'type': 'boolean',

View File

@@ -54,7 +54,6 @@ import { basename } from 'vs/base/common/resources';
class CodeRendererMain extends Disposable {
private workbench: Workbench;
private readonly environmentService: WorkbenchEnvironmentService;
constructor(configuration: IWindowConfiguration) {
@@ -116,17 +115,17 @@ class CodeRendererMain extends Disposable {
mark('willStartWorkbench');
// Create Workbench
this.workbench = new Workbench(document.body, services.serviceCollection, services.logService);
const workbench = new Workbench(document.body, services.serviceCollection, services.logService);
// Layout
this._register(addDisposableListener(window, EventType.RESIZE, e => this.onWindowResize(e, true)));
this._register(addDisposableListener(window, EventType.RESIZE, e => this.onWindowResize(e, true, workbench)));
// Workbench Lifecycle
this._register(this.workbench.onShutdown(() => this.dispose()));
this._register(this.workbench.onWillShutdown(event => event.join(services.storageService.close())));
this._register(workbench.onShutdown(() => this.dispose()));
this._register(workbench.onWillShutdown(event => event.join(services.storageService.close())));
// Startup
const instantiationService = this.workbench.startup();
const instantiationService = workbench.startup();
// Window
this._register(instantiationService.createInstance(ElectronWindow));
@@ -145,7 +144,7 @@ class CodeRendererMain extends Disposable {
services.logService.trace('workbench configuration', JSON.stringify(this.environmentService.configuration));
}
private onWindowResize(e: Event, retry: boolean): void {
private onWindowResize(e: Event, retry: boolean, workbench: Workbench): void {
if (e.target === window) {
if (window.document && window.document.body && window.document.body.clientWidth === 0) {
// TODO@Ben this is an electron issue on macOS when simple fullscreen is enabled
@@ -154,12 +153,12 @@ class CodeRendererMain extends Disposable {
// call at the next animation frame once, in the hope that the dimensions are
// proper then.
if (retry) {
scheduleAtNextAnimationFrame(() => this.onWindowResize(e, false));
scheduleAtNextAnimationFrame(() => this.onWindowResize(e, false, workbench));
}
return;
}
this.workbench.layout();
workbench.layout();
}
}
@@ -168,7 +167,7 @@ class CodeRendererMain extends Disposable {
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// NOTE: DO NOT ADD ANY OTHER SERVICE INTO THE COLLECTION HERE.
// CONTRIBUTE IT VIA WORKBENCH.MAIN.TS AND registerSingleton().
// CONTRIBUTE IT VIA WORKBENCH.DESKTOP.MAIN.TS AND registerSingleton().
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Main Process

View File

@@ -213,6 +213,8 @@ export class ElectronWindow extends Disposable {
this._register(this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('window.zoomLevel')) {
this.updateWindowZoomLevel();
} else if (e.affectsConfiguration('keyboard.touchbar.enabled') || e.affectsConfiguration('keyboard.touchbar.ignored')) {
this.updateTouchbarMenu();
}
}));
@@ -340,11 +342,8 @@ export class ElectronWindow extends Disposable {
}
private updateTouchbarMenu(): void {
if (
!isMacintosh || // macOS only
!this.configurationService.getValue<boolean>('keyboard.touchbar.enabled') // disabled via setting
) {
return;
if (!isMacintosh) {
return; // macOS only
}
// Dispose old
@@ -366,31 +365,40 @@ export class ElectronWindow extends Disposable {
const actions: Array<MenuItemAction | Separator> = [];
const disabled = this.configurationService.getValue<boolean>('keyboard.touchbar.enabled') === false;
const ignoredItems = this.configurationService.getValue<string[]>('keyboard.touchbar.ignored') || [];
// Fill actions into groups respecting order
this.touchBarDisposables.add(createAndFillInActionBarActions(this.touchBarMenu, undefined, actions));
// Convert into command action multi array
const items: ICommandAction[][] = [];
let group: ICommandAction[] = [];
for (const action of actions) {
if (!disabled) {
for (const action of actions) {
// Command
if (action instanceof MenuItemAction) {
group.push(action.item);
}
// Command
if (action instanceof MenuItemAction) {
if (ignoredItems.indexOf(action.item.id) >= 0) {
continue; // ignored
}
// Separator
else if (action instanceof Separator) {
if (group.length) {
items.push(group);
group.push(action.item);
}
group = [];
}
}
// Separator
else if (action instanceof Separator) {
if (group.length) {
items.push(group);
}
if (group.length) {
items.push(group);
group = [];
}
}
if (group.length) {
items.push(group);
}
}
// Only update if the actions have changed