chore(vscode): update to 1.56.0

This commit is contained in:
Akash Satheesan
2021-04-30 20:25:17 +05:30
1749 changed files with 88014 additions and 43316 deletions

View File

@@ -35,7 +35,7 @@ export class CloseCurrentWindowAction extends Action {
super(id, label);
}
async run(): Promise<void> {
override async run(): Promise<void> {
this.nativeHostService.closeWindow();
}
}
@@ -81,7 +81,7 @@ export class ZoomInAction extends BaseZoomAction {
super(id, label, configurationService);
}
async run(): Promise<void> {
override async run(): Promise<void> {
this.setConfiguredZoomLevel(getZoomLevel() + 1);
}
}
@@ -99,7 +99,7 @@ export class ZoomOutAction extends BaseZoomAction {
super(id, label, configurationService);
}
async run(): Promise<void> {
override async run(): Promise<void> {
this.setConfiguredZoomLevel(getZoomLevel() - 1);
}
}
@@ -117,7 +117,7 @@ export class ZoomResetAction extends BaseZoomAction {
super(id, label, configurationService);
}
async run(): Promise<void> {
override async run(): Promise<void> {
this.setConfiguredZoomLevel(0);
}
}
@@ -149,7 +149,7 @@ export abstract class BaseSwitchWindow extends Action {
protected abstract isQuickNavigate(): boolean;
async run(): Promise<void> {
override async run(): Promise<void> {
const currentWindowId = this.nativeHostService.windowId;
const windows = await this.nativeHostService.getWindows();

View File

@@ -36,12 +36,20 @@ import { IJSONSchema } from 'vs/base/common/jsonSchema';
// Actions: Window
(function registerWindowActions(): void {
registry.registerWorkbenchAction(SyncActionDescriptor.from(CloseCurrentWindowAction, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_W }), 'Close Window');
registry.registerWorkbenchAction(SyncActionDescriptor.from(SwitchWindow, { primary: 0, mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_W } }), 'Switch Window...');
registry.registerWorkbenchAction(SyncActionDescriptor.from(QuickSwitchWindow), 'Quick Switch Window...');
// Close window
registry.registerWorkbenchAction(SyncActionDescriptor.from(CloseCurrentWindowAction, {
mac: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_W },
linux: { primary: KeyMod.Alt | KeyCode.F4, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_W] },
win: { primary: KeyMod.Alt | KeyCode.F4, secondary: [KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_W] }
}
), 'Close Window');
// Close the window when the last editor is closed by reusing the same keybinding
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: CloseCurrentWindowAction.ID, // close the window when the last editor is closed by reusing the same keybinding
id: CloseCurrentWindowAction.ID,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(EditorsVisibleContext.toNegated(), SingleEditorGroupsContext),
primary: KeyMod.CtrlCmd | KeyCode.KEY_W,
@@ -51,6 +59,7 @@ import { IJSONSchema } from 'vs/base/common/jsonSchema';
}
});
// Quit
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'workbench.action.quit',
weight: KeybindingWeight.WorkbenchContrib,

View File

@@ -3,28 +3,30 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { INativeWorkbenchConfiguration, NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
import { INativeWorkbenchConfiguration, INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
import { ILogService } from 'vs/platform/log/common/log';
import { Schemas } from 'vs/base/common/network';
import { IFileService } from 'vs/platform/files/common/files';
import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider';
import { INativeHostService } from 'vs/platform/native/electron-sandbox/native';
import { simpleHomeDir, simpleFileSystemProvider, simpleWorkspaceDir, simpleTmpDir, simpleUserDataDir } from 'vs/workbench/electron-sandbox/sandbox.simpleservices';
import { productService, SharedDesktopMain } from 'vs/workbench/electron-sandbox/shared.desktop.main';
import { initFileSystem, simpleFileSystemProvider, simpleWorkspaceDir } from 'vs/workbench/electron-sandbox/sandbox.simpleservices';
import { SharedDesktopMain } from 'vs/workbench/electron-sandbox/shared.desktop.main';
class DesktopMain extends SharedDesktopMain {
constructor(configuration: INativeWorkbenchConfiguration) {
super({ ...configuration, workspace: { id: configuration.workspace?.id ?? '4064f6ec-cb38-4ad0-af64-ee6467e63c82', uri: simpleWorkspaceDir } }, new NativeWorkbenchEnvironmentService(configuration, { homeDir: simpleHomeDir.fsPath, tmpDir: simpleTmpDir.fsPath, userDataDir: simpleUserDataDir.fsPath }, productService));
super({ ...configuration, workspace: { id: configuration.workspace?.id ?? '4064f6ec-cb38-4ad0-af64-ee6467e63c82', uri: simpleWorkspaceDir } });
}
protected registerFileSystemProviders(fileService: IFileService, logService: ILogService, nativeHostService: INativeHostService): void {
protected registerFileSystemProviders(environmentService: INativeWorkbenchEnvironmentService, fileService: IFileService, logService: ILogService): Promise<void> {
// Local Files
fileService.registerProvider(Schemas.file, simpleFileSystemProvider);
// User Data Provider
fileService.registerProvider(Schemas.userData, new FileUserDataProvider(Schemas.file, simpleFileSystemProvider, Schemas.userData, logService));
// Init our in-memory file system
return initFileSystem(environmentService, fileService);
}
}

View File

@@ -20,6 +20,7 @@ import { NativeDialogHandler } from 'vs/workbench/electron-sandbox/parts/dialogs
import { DialogService } from 'vs/workbench/services/dialogs/common/dialogService';
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { Disposable } from 'vs/base/common/lifecycle';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
export class DialogHandlerContribution extends Disposable implements IWorkbenchContribution {
private nativeImpl: IDialogHandler;
@@ -35,13 +36,14 @@ export class DialogHandlerContribution extends Disposable implements IWorkbenchC
@ILayoutService layoutService: ILayoutService,
@IThemeService themeService: IThemeService,
@IKeybindingService keybindingService: IKeybindingService,
@IInstantiationService instantiationService: IInstantiationService,
@IProductService productService: IProductService,
@IClipboardService clipboardService: IClipboardService,
@INativeHostService nativeHostService: INativeHostService
) {
super();
this.browserImpl = new BrowserDialogHandler(logService, layoutService, themeService, keybindingService, productService, clipboardService);
this.browserImpl = new BrowserDialogHandler(logService, layoutService, themeService, keybindingService, instantiationService, productService, clipboardService);
this.nativeImpl = new NativeDialogHandler(logService, nativeHostService, productService, clipboardService);
this.model = (this.dialogService as DialogService).model;
@@ -76,7 +78,7 @@ export class DialogHandlerContribution extends Disposable implements IWorkbenchC
// Message
else if (this.currentDialog.args.showArgs) {
const args = this.currentDialog.args.showArgs;
result = this.useCustomDialog || args.options?.useCustom ?
result = (this.useCustomDialog || args.options?.custom) ?
await this.browserImpl.show(args.severity, args.message, args.buttons, args.options) :
await this.nativeImpl.show(args.severity, args.message, args.buttons, args.options);
}

View File

@@ -39,7 +39,7 @@ export class NativeMenubarControl extends MenubarControl {
@IStorageService storageService: IStorageService,
@INotificationService notificationService: INotificationService,
@IPreferencesService preferencesService: IPreferencesService,
@INativeWorkbenchEnvironmentService protected readonly environmentService: INativeWorkbenchEnvironmentService,
@INativeWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService,
@IAccessibilityService accessibilityService: IAccessibilityService,
@IMenubarService private readonly menubarService: IMenubarService,
@IHostService hostService: IHostService,

View File

@@ -41,14 +41,16 @@ export class TitlebarPart extends BrowserTitleBarPart {
return 22;
}
get minimumHeight(): number { return isMacintosh ? this.getMacTitlebarSize() / getZoomFactor() : super.minimumHeight; }
get maximumHeight(): number { return this.minimumHeight; }
override get minimumHeight(): number { return isMacintosh ? this.getMacTitlebarSize() / getZoomFactor() : super.minimumHeight; }
override get maximumHeight(): number { return this.minimumHeight; }
protected override readonly environmentService: INativeWorkbenchEnvironmentService;
constructor(
@IContextMenuService contextMenuService: IContextMenuService,
@IConfigurationService protected readonly configurationService: IConfigurationService,
@IConfigurationService configurationService: IConfigurationService,
@IEditorService editorService: IEditorService,
@INativeWorkbenchEnvironmentService protected readonly environmentService: INativeWorkbenchEnvironmentService,
@INativeWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IInstantiationService instantiationService: IInstantiationService,
@IThemeService themeService: IThemeService,
@@ -62,6 +64,8 @@ export class TitlebarPart extends BrowserTitleBarPart {
@INativeHostService private readonly nativeHostService: INativeHostService
) {
super(contextMenuService, configurationService, editorService, environmentService, contextService, instantiationService, themeService, labelService, storageService, layoutService, menuService, contextKeyService, hostService, productService);
this.environmentService = environmentService;
}
private onUpdateAppIconDragBehavior(): void {
@@ -105,7 +109,7 @@ export class TitlebarPart extends BrowserTitleBarPart {
}
}
protected onMenubarVisibilityChanged(visible: boolean): void {
protected override onMenubarVisibilityChanged(visible: boolean): void {
// Hide title when toggling menu bar
if ((isWindows || isLinux) && this.currentMenubarVisibility === 'toggle' && visible) {
// Hack to fix issue #52522 with layered webkit-app-region elements appearing under cursor
@@ -118,7 +122,7 @@ export class TitlebarPart extends BrowserTitleBarPart {
super.onMenubarVisibilityChanged(visible);
}
protected onConfigurationChanged(event: IConfigurationChangeEvent): void {
protected override onConfigurationChanged(event: IConfigurationChangeEvent): void {
super.onConfigurationChanged(event);
if (event.affectsConfiguration('window.doubleClickIconToClose')) {
@@ -128,7 +132,7 @@ export class TitlebarPart extends BrowserTitleBarPart {
}
}
protected adjustTitleMarginToCenter(): void {
protected override adjustTitleMarginToCenter(): void {
if (this.customMenubar && this.menubar) {
const leftMarker = (this.appIcon ? this.appIcon.clientWidth : 0) + this.menubar.clientWidth + 10;
const rightMarker = this.element.clientWidth - (this.windowControls ? this.windowControls.clientWidth : 0) - 10;
@@ -150,7 +154,7 @@ export class TitlebarPart extends BrowserTitleBarPart {
this.title.style.maxWidth = `calc(100vw - ${2 * ((this.windowControls?.clientWidth || 70) + 10)}px)`;
}
protected installMenubar(): void {
protected override installMenubar(): void {
super.installMenubar();
if (this.menubar) {
@@ -162,7 +166,7 @@ export class TitlebarPart extends BrowserTitleBarPart {
}
}
createContentArea(parent: HTMLElement): HTMLElement {
override createContentArea(parent: HTMLElement): HTMLElement {
const ret = super.createContentArea(parent);
// Native menu controller
@@ -219,7 +223,7 @@ export class TitlebarPart extends BrowserTitleBarPart {
return ret;
}
updateLayout(dimension: Dimension): void {
override updateLayout(dimension: Dimension): void {
this.lastLayoutDimensions = dimension;
if (getTitleBarStyle(this.configurationService) === 'custom') {

View File

@@ -11,16 +11,10 @@ import { Event } from 'vs/base/common/event';
import { IAddressProvider } from 'vs/platform/remote/common/remoteAgentConnection';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IExtensionService, NullExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { isWindows } from 'vs/base/common/platform';
import { IProcessEnvironment, isWindows, OperatingSystem } from 'vs/base/common/platform';
import { IWebviewService, WebviewContentOptions, WebviewElement, WebviewExtensionDescription, WebviewOptions, WebviewOverlay } from 'vs/workbench/contrib/webview/browser/webview';
import { ITunnelProvider, ITunnelService, RemoteTunnel, TunnelProviderFeatures } from 'vs/platform/remote/common/tunnel';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { ITaskProvider, ITaskService, ITaskSummary, ProblemMatcherRunOptions, Task, TaskFilter, TaskTerminateResponse, WorkspaceFolderTaskResult } from 'vs/workbench/contrib/tasks/common/taskService';
import { Action } from 'vs/base/common/actions';
import { LinkedMap } from 'vs/base/common/map';
import { IWorkspace, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { CustomTask, ContributedTask, InMemoryTask, TaskRunSource, ConfiguringTask, TaskIdentifier, TaskSorter } from 'vs/workbench/contrib/tasks/common/tasks';
import { TaskSystemInfo } from 'vs/workbench/contrib/tasks/common/taskSystem';
import { joinPath } from 'vs/base/common/resources';
import { VSBuffer } from 'vs/base/common/buffer';
import { TerminalInstanceService } from 'vs/workbench/contrib/terminal/browser/terminalInstanceService';
@@ -33,13 +27,12 @@ import { ILogService } from 'vs/platform/log/common/log';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
import { IShellLaunchConfigResolveOptions, ITerminalProfile, ITerminalProfileResolverService } from 'vs/workbench/contrib/terminal/common/terminal';
import { IShellLaunchConfig } from 'vs/platform/terminal/common/terminal';
//#region Environment
export const simpleHomeDir = URI.file(isWindows ? '\\sandbox-home-dir' : '/sandbox-home-dir');
export const simpleTmpDir = URI.file(isWindows ? '\\sandbox-tmp-dir' : '/sandbox-tmp-dir');
export const simpleUserDataDir = URI.file(isWindows ? '\\sandbox-user-data-dir' : '/sandbox-user-data-dir');
//#region Workspace
export const simpleWorkspaceDir = URI.file(isWindows ? '\\simpleWorkspace' : '/simpleWorkspace');
@@ -53,21 +46,23 @@ class SimpleFileSystemProvider extends InMemoryFileSystemProvider { }
export const simpleFileSystemProvider = new SimpleFileSystemProvider();
simpleFileSystemProvider.mkdir(simpleHomeDir);
simpleFileSystemProvider.mkdir(simpleTmpDir);
simpleFileSystemProvider.mkdir(simpleUserDataDir);
simpleFileSystemProvider.mkdir(joinPath(simpleUserDataDir, 'User'));
simpleFileSystemProvider.writeFile(joinPath(simpleUserDataDir, 'User', 'settings.json'), VSBuffer.fromString(JSON.stringify({
'window.zoomLevel': 1,
'workbench.colorTheme': 'Default Light+',
export async function initFileSystem(environmentService: INativeWorkbenchEnvironmentService, fileService: IFileService): Promise<void> {
await fileService.createFolder(environmentService.userHome);
await fileService.createFolder(environmentService.tmpDir);
}, undefined, '\t')).buffer, { create: true, overwrite: true, unlock: false });
simpleFileSystemProvider.writeFile(joinPath(simpleUserDataDir, 'User', 'keybindings.json'), VSBuffer.fromString(JSON.stringify([
{
'key': 'f12',
'command': 'workbench.action.toggleDevTools'
}
], undefined, '\t')).buffer, { create: true, overwrite: true, unlock: false });
const userData = URI.file(environmentService.userDataPath);
await fileService.writeFile(joinPath(userData, 'User', 'settings.json'), VSBuffer.fromString(JSON.stringify({
'window.zoomLevel': 1,
'workbench.colorTheme': 'Default Light+',
}, undefined, '\t')));
await fileService.writeFile(joinPath(userData, 'User', 'keybindings.json'), VSBuffer.fromString(JSON.stringify([
{
'key': 'f12',
'command': 'workbench.action.toggleDevTools'
}
], undefined, '\t')));
}
function createWorkspaceFile(parent: string, name: string, content: string = ''): void {
simpleFileSystemProvider.writeFile(joinPath(simpleWorkspaceDir, parent, name), VSBuffer.fromString(content).buffer, { create: true, overwrite: true, unlock: false });
@@ -232,8 +227,8 @@ suite("Extension Tests", function () {
// Defines a Mocha unit test
test("Something 1", function() {
assert.equal(-1, [1, 2, 3].indexOf(5));
assert.equal(-1, [1, 2, 3].indexOf(0));
assert.strictEqual(-1, [1, 2, 3].indexOf(5));
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
});
});`);
@@ -279,6 +274,7 @@ class SimpleWebviewService implements IWebviewService {
declare readonly _serviceBrand: undefined;
readonly activeWebview = undefined;
readonly onDidChangeActiveWebview = Event.None;
createWebviewElement(id: string, options: WebviewOptions, contentOptions: WebviewContentOptions, extension: WebviewExtensionDescription | undefined): WebviewElement { throw new Error('Method not implemented.'); }
createWebviewOverlay(id: string, options: WebviewOptions, contentOptions: WebviewContentOptions, extension: WebviewExtensionDescription | undefined): WebviewOverlay { throw new Error('Method not implemented.'); }
@@ -313,53 +309,6 @@ registerSingleton(ITunnelService, SimpleTunnelService);
//#endregion
//#region Task
class SimpleTaskService implements ITaskService {
declare readonly _serviceBrand: undefined;
onDidStateChange = Event.None;
supportsMultipleTaskExecutions = false;
configureAction(): Action { throw new Error('Method not implemented.'); }
build(): Promise<ITaskSummary> { throw new Error('Method not implemented.'); }
runTest(): Promise<ITaskSummary> { throw new Error('Method not implemented.'); }
run(task: CustomTask | ContributedTask | InMemoryTask | undefined, options?: ProblemMatcherRunOptions): Promise<ITaskSummary | undefined> { throw new Error('Method not implemented.'); }
inTerminal(): boolean { throw new Error('Method not implemented.'); }
isActive(): Promise<boolean> { throw new Error('Method not implemented.'); }
getActiveTasks(): Promise<Task[]> { throw new Error('Method not implemented.'); }
getBusyTasks(): Promise<Task[]> { throw new Error('Method not implemented.'); }
restart(task: Task): void { throw new Error('Method not implemented.'); }
terminate(task: Task): Promise<TaskTerminateResponse> { throw new Error('Method not implemented.'); }
terminateAll(): Promise<TaskTerminateResponse[]> { throw new Error('Method not implemented.'); }
tasks(filter?: TaskFilter): Promise<Task[]> { throw new Error('Method not implemented.'); }
taskTypes(): string[] { throw new Error('Method not implemented.'); }
getWorkspaceTasks(runSource?: TaskRunSource): Promise<Map<string, WorkspaceFolderTaskResult>> { throw new Error('Method not implemented.'); }
readRecentTasks(): Promise<(CustomTask | ContributedTask | InMemoryTask | ConfiguringTask)[]> { throw new Error('Method not implemented.'); }
getTask(workspaceFolder: string | IWorkspace | IWorkspaceFolder, alias: string | TaskIdentifier, compareId?: boolean): Promise<CustomTask | ContributedTask | InMemoryTask | undefined> { throw new Error('Method not implemented.'); }
tryResolveTask(configuringTask: ConfiguringTask): Promise<CustomTask | ContributedTask | InMemoryTask | undefined> { throw new Error('Method not implemented.'); }
getTasksForGroup(group: string): Promise<Task[]> { throw new Error('Method not implemented.'); }
getRecentlyUsedTasks(): LinkedMap<string, string> { throw new Error('Method not implemented.'); }
removeRecentlyUsedTask(taskRecentlyUsedKey: string): void { throw new Error('Method not implemented.'); }
migrateRecentTasks(tasks: Task[]): Promise<void> { throw new Error('Method not implemented.'); }
createSorter(): TaskSorter { throw new Error('Method not implemented.'); }
getTaskDescription(task: CustomTask | ContributedTask | InMemoryTask | ConfiguringTask): string | undefined { throw new Error('Method not implemented.'); }
canCustomize(task: CustomTask | ContributedTask): boolean { throw new Error('Method not implemented.'); }
customize(task: CustomTask | ContributedTask | ConfiguringTask, properties?: {}, openConfig?: boolean): Promise<void> { throw new Error('Method not implemented.'); }
openConfig(task: CustomTask | ConfiguringTask | undefined): Promise<boolean> { throw new Error('Method not implemented.'); }
registerTaskProvider(taskProvider: ITaskProvider, type: string): IDisposable { throw new Error('Method not implemented.'); }
registerTaskSystem(scheme: string, taskSystemInfo: TaskSystemInfo): void { throw new Error('Method not implemented.'); }
registerSupportedExecutions(custom?: boolean, shell?: boolean, process?: boolean): void { throw new Error('Method not implemented.'); }
setJsonTasksSupported(areSuppored: Promise<boolean>): void { throw new Error('Method not implemented.'); }
extensionCallbackTaskComplete(task: Task, result: number | undefined): Promise<void> { throw new Error('Method not implemented.'); }
}
registerSingleton(ITaskService, SimpleTaskService);
//#endregion
//#region Terminal Instance
class SimpleTerminalInstanceService extends TerminalInstanceService { }
@@ -369,6 +318,25 @@ registerSingleton(ITerminalInstanceService, SimpleTerminalInstanceService);
//#endregion
//#region Terminal Profile Resolver Service
class SimpleTerminalProfileResolverService implements ITerminalProfileResolverService {
_serviceBrand: undefined;
resolveIcon(shellLaunchConfig: IShellLaunchConfig, os: OperatingSystem): void { }
async resolveShellLaunchConfig(shellLaunchConfig: IShellLaunchConfig, options: IShellLaunchConfigResolveOptions): Promise<void> { }
getDefaultProfile(options: IShellLaunchConfigResolveOptions): Promise<ITerminalProfile> { throw new Error('Method not implemented.'); }
getDefaultShell(options: IShellLaunchConfigResolveOptions): Promise<string> { throw new Error('Method not implemented.'); }
getDefaultShellArgs(options: IShellLaunchConfigResolveOptions): Promise<string | string[]> { throw new Error('Method not implemented.'); }
getShellEnvironment(remoteAuthority: string | undefined): Promise<IProcessEnvironment> { throw new Error('Method not implemented.'); }
getSafeConfigValue(key: string, os: OperatingSystem): unknown | undefined { throw new Error('Method not implemented.'); }
getSafeConfigValueFullKey(key: string): unknown | undefined { throw new Error('Method not implemented.'); }
}
registerSingleton(ITerminalProfileResolverService, SimpleTerminalProfileResolverService);
//#region Search Service
class SimpleSearchService extends SearchService {

View File

@@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import product from 'vs/platform/product/common/product';
import { zoomLevelToZoomFactor } from 'vs/platform/windows/common/windows';
import { mark } from 'vs/base/common/performance';
import { Workbench } from 'vs/workbench/browser/workbench';
import { NativeWindow } from 'vs/workbench/electron-sandbox/window';
import { setZoomLevel, setZoomFactor, setFullscreen } from 'vs/base/browser/browser';
@@ -12,7 +12,7 @@ import { domContentLoaded } from 'vs/base/browser/dom';
import { onUnexpectedError } from 'vs/base/common/errors';
import { URI } from 'vs/base/common/uri';
import { WorkspaceService } from 'vs/workbench/services/configuration/browser/configurationService';
import { INativeWorkbenchConfiguration, INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
import { INativeWorkbenchConfiguration, INativeWorkbenchEnvironmentService, NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier, IWorkspaceInitializationPayload, reviveIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { ILoggerService, ILogService } from 'vs/platform/log/common/log';
@@ -41,21 +41,17 @@ import { UriIdentityService } from 'vs/workbench/services/uriIdentity/common/uri
import { KeyboardLayoutService } from 'vs/workbench/services/keybinding/electron-sandbox/nativeKeyboardLayout';
import { IKeyboardLayoutService } from 'vs/platform/keyboardLayout/common/keyboardLayout';
import { ElectronIPCMainProcessService } from 'vs/platform/ipc/electron-sandbox/mainProcessService';
import { LoggerChannelClient } from 'vs/platform/log/common/logIpc';
import { LoggerChannelClient, LogLevelChannelClient } from 'vs/platform/log/common/logIpc';
import { ProxyChannel } from 'vs/base/parts/ipc/common/ipc';
import product from 'vs/platform/product/common/product';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { NativeLogService } from 'vs/workbench/services/log/electron-sandbox/logService';
export const productService = { _serviceBrand: undefined, ...product };
import { WorkspaceTrustManagementService } from 'vs/workbench/services/workspaces/common/workspaceTrust';
import { IWorkspaceTrustManagementService } from 'vs/platform/workspace/common/workspaceTrust';
import { registerWindowDriver } from 'vs/platform/driver/electron-sandbox/driver';
export abstract class SharedDesktopMain extends Disposable {
protected readonly productService: IProductService = productService;
constructor(
protected readonly configuration: INativeWorkbenchConfiguration,
protected readonly environmentService: INativeWorkbenchEnvironmentService
protected readonly configuration: INativeWorkbenchConfiguration
) {
super();
@@ -101,10 +97,9 @@ export abstract class SharedDesktopMain extends Disposable {
}
async open(): Promise<void> {
const services = await this.initServices();
await domContentLoaded();
mark('code/willStartWorkbench');
// Init services and wait for DOM to be ready in parallel
const [services] = await Promise.all([this.initServices(), domContentLoaded()]);
// Create Workbench
const workbench = new Workbench(document.body, services.serviceCollection, services.logService);
@@ -121,19 +116,20 @@ export abstract class SharedDesktopMain extends Disposable {
// Logging
services.logService.trace('workbench configuration', JSON.stringify(this.configuration));
// Allow subclass to participate
this.joinOpen(instantiationService);
// Driver
if (this.configuration.driver) {
instantiationService.invokeFunction(async accessor => this._register(await registerWindowDriver(accessor, this.configuration.windowId)));
}
}
private registerListeners(workbench: Workbench, storageService: NativeStorageService): void {
// Workbench Lifecycle
this._register(workbench.onWillShutdown(event => event.join(storageService.close(), 'join.closeStorage')));
this._register(workbench.onShutdown(() => this.dispose()));
this._register(workbench.onDidShutdown(() => this.dispose()));
}
protected abstract registerFileSystemProviders(fileService: IFileService, logService: ILogService, nativeHostService: INativeHostService): void;
protected joinOpen(instantiationService: IInstantiationService): void { }
protected abstract registerFileSystemProviders(environmentService: INativeWorkbenchEnvironmentService, fileService: IFileService, logService: ILogService, nativeHostService: INativeHostService): void | Promise<void>;
private async initServices(): Promise<{ serviceCollection: ServiceCollection, logService: ILogService, storageService: NativeStorageService }> {
const serviceCollection = new ServiceCollection();
@@ -156,18 +152,21 @@ export abstract class SharedDesktopMain extends Disposable {
const mainProcessService = this._register(new ElectronIPCMainProcessService(this.configuration.windowId));
serviceCollection.set(IMainProcessService, mainProcessService);
// Environment
serviceCollection.set(INativeWorkbenchEnvironmentService, this.environmentService);
// Product
serviceCollection.set(IProductService, this.productService);
const productService: IProductService = { _serviceBrand: undefined, ...product };
serviceCollection.set(IProductService, productService);
// Environment
const environmentService = new NativeWorkbenchEnvironmentService(this.configuration, productService);
serviceCollection.set(INativeWorkbenchEnvironmentService, environmentService);
// Logger
const loggerService = new LoggerChannelClient(mainProcessService.getChannel('logger'));
const logLevelChannelClient = new LogLevelChannelClient(mainProcessService.getChannel('logLevel'));
const loggerService = new LoggerChannelClient(environmentService.configuration.logLevel, logLevelChannelClient.onDidChangeLogLevel, mainProcessService.getChannel('logger'));
serviceCollection.set(ILoggerService, loggerService);
// Log
const logService = this._register(new NativeLogService(`renderer${this.configuration.windowId}`, loggerService, mainProcessService, this.environmentService));
const logService = this._register(new NativeLogService(`renderer${this.configuration.windowId}`, environmentService.configuration.logLevel, loggerService, logLevelChannelClient, environmentService));
serviceCollection.set(ILogService, logService);
// Remote
@@ -193,7 +192,7 @@ export abstract class SharedDesktopMain extends Disposable {
serviceCollection.set(ISignService, signService);
// Remote Agent
const remoteAgentService = this._register(new RemoteAgentService(this.environmentService, this.productService, remoteAuthorityResolverService, signService, logService));
const remoteAgentService = this._register(new RemoteAgentService(environmentService, productService, remoteAuthorityResolverService, signService, logService));
serviceCollection.set(IRemoteAgentService, remoteAgentService);
// Native Host
@@ -204,7 +203,10 @@ export abstract class SharedDesktopMain extends Disposable {
const fileService = this._register(new FileService(logService));
serviceCollection.set(IFileService, fileService);
this.registerFileSystemProviders(fileService, logService, nativeHostService);
const result = this.registerFileSystemProviders(environmentService, fileService, logService, nativeHostService);
if (result instanceof Promise) {
await result;
}
// Uri Identity
const uriIdentityService = new UriIdentityService(fileService);
@@ -230,10 +232,10 @@ export abstract class SharedDesktopMain extends Disposable {
fileService.registerProvider(Schemas.vscodeRemote, remoteFileSystemProvider);
}
const payload = this.resolveWorkspaceInitializationPayload();
const payload = this.resolveWorkspaceInitializationPayload(environmentService);
const services = await Promise.all([
this.createWorkspaceService(payload, fileService, remoteAgentService, uriIdentityService, logService).then(service => {
const [configurationService, storageService] = await Promise.all([
this.createWorkspaceService(payload, environmentService, fileService, remoteAgentService, uriIdentityService, logService).then(service => {
// Workspace
serviceCollection.set(IWorkspaceContextService, service);
@@ -244,7 +246,7 @@ export abstract class SharedDesktopMain extends Disposable {
return service;
}),
this.createStorageService(payload, mainProcessService).then(service => {
this.createStorageService(payload, environmentService, mainProcessService).then(service => {
// Storage
serviceCollection.set(IStorageService, service);
@@ -261,6 +263,13 @@ export abstract class SharedDesktopMain extends Disposable {
})
]);
// Workspace Trust Service
const workspaceTrustManagementService = new WorkspaceTrustManagementService(configurationService, environmentService, storageService, uriIdentityService, configurationService);
serviceCollection.set(IWorkspaceTrustManagementService, workspaceTrustManagementService);
// Update workspace trust so that configuration is updated accordingly
configurationService.updateWorkspaceTrust(workspaceTrustManagementService.isWorkpaceTrusted());
this._register(workspaceTrustManagementService.onDidChangeTrust(() => configurationService.updateWorkspaceTrust(workspaceTrustManagementService.isWorkpaceTrusted())));
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
@@ -275,10 +284,10 @@ export abstract class SharedDesktopMain extends Disposable {
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
return { serviceCollection, logService, storageService: services[1] };
return { serviceCollection, logService, storageService };
}
private resolveWorkspaceInitializationPayload(): IWorkspaceInitializationPayload {
private resolveWorkspaceInitializationPayload(environmentService: INativeWorkbenchEnvironmentService): IWorkspaceInitializationPayload {
let workspaceInitializationPayload: IWorkspaceInitializationPayload | undefined = this.configuration.workspace;
// Fallback to empty workspace if we have no payload yet.
@@ -286,7 +295,7 @@ export abstract class SharedDesktopMain extends Disposable {
let id: string;
if (this.configuration.backupPath) {
id = basename(this.configuration.backupPath); // we know the backupPath must be a unique path so we leverage its name as workspace ID
} else if (this.environmentService.isExtensionDevelopment) {
} else if (environmentService.isExtensionDevelopment) {
id = 'ext-dev'; // extension development window never stores backups and is a singleton
} else {
throw new Error('Unexpected window configuration without backupPath');
@@ -298,8 +307,8 @@ export abstract class SharedDesktopMain extends Disposable {
return workspaceInitializationPayload;
}
private async createWorkspaceService(payload: IWorkspaceInitializationPayload, fileService: FileService, remoteAgentService: IRemoteAgentService, uriIdentityService: IUriIdentityService, logService: ILogService): Promise<WorkspaceService> {
const workspaceService = new WorkspaceService({ remoteAuthority: this.environmentService.remoteAuthority, configurationCache: new ConfigurationCache(URI.file(this.environmentService.userDataPath), fileService) }, this.environmentService, fileService, remoteAgentService, uriIdentityService, logService);
private async createWorkspaceService(payload: IWorkspaceInitializationPayload, environmentService: INativeWorkbenchEnvironmentService, fileService: FileService, remoteAgentService: IRemoteAgentService, uriIdentityService: IUriIdentityService, logService: ILogService): Promise<WorkspaceService> {
const workspaceService = new WorkspaceService({ remoteAuthority: environmentService.remoteAuthority, configurationCache: new ConfigurationCache(URI.file(environmentService.userDataPath), fileService) }, environmentService, fileService, remoteAgentService, uriIdentityService, logService);
try {
await workspaceService.initialize(payload);
@@ -312,8 +321,8 @@ export abstract class SharedDesktopMain extends Disposable {
}
}
private async createStorageService(payload: IWorkspaceInitializationPayload, mainProcessService: IMainProcessService): Promise<NativeStorageService> {
const storageService = new NativeStorageService(payload, mainProcessService, this.environmentService);
private async createStorageService(payload: IWorkspaceInitializationPayload, environmentService: INativeWorkbenchEnvironmentService, mainProcessService: IMainProcessService): Promise<NativeStorageService> {
const storageService = new NativeStorageService(payload, mainProcessService, environmentService);
try {
await storageService.initialize();

View File

@@ -48,7 +48,8 @@ import { posix, dirname } from 'vs/base/common/path';
import { getBaseLabel } from 'vs/base/common/labels';
import { ITunnelService, extractLocalHostUriMetaDataForPortMapping } from 'vs/platform/remote/common/tunnel';
import { IWorkbenchLayoutService, Parts, positionFromString, Position } from 'vs/workbench/services/layout/browser/layoutService';
import { IWorkingCopyService, WorkingCopyCapabilities } from 'vs/workbench/services/workingCopy/common/workingCopyService';
import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
import { WorkingCopyCapabilities } from 'vs/workbench/services/workingCopy/common/workingCopy';
import { AutoSaveMode, IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
import { Event } from 'vs/base/common/event';
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
@@ -57,6 +58,8 @@ import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editor
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { AuthInfo } from 'vs/base/parts/sandbox/electron-sandbox/electronTypes';
import { ILogService } from 'vs/platform/log/common/log';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { whenEditorClosed } from 'vs/workbench/browser/editor';
export class NativeWindow extends Disposable {
@@ -105,7 +108,8 @@ export class NativeWindow extends Disposable {
@IRemoteAuthorityResolverService private readonly remoteAuthorityResolverService: IRemoteAuthorityResolverService,
@IDialogService private readonly dialogService: IDialogService,
@IStorageService private readonly storageService: IStorageService,
@ILogService private readonly logService: ILogService
@ILogService private readonly logService: ILogService,
@IInstantiationService private readonly instantiationService: IInstantiationService
) {
super();
@@ -467,7 +471,7 @@ export class NativeWindow extends Disposable {
this.lifecycleService.when(LifecyclePhase.Ready).then(() => this.nativeHostService.notifyReady());
// Integrity warning
this.integrityService.isPure().then(res => this.titleService.updateProperties({ isPure: res.isPure }));
this.integrityService.isPure().then(({ isPure }) => this.titleService.updateProperties({ isPure }));
// Root warning
this.lifecycleService.when(LifecyclePhase.Restored).then(async () => {
@@ -664,8 +668,8 @@ export class NativeWindow extends Disposable {
private async trackClosedWaitFiles(waitMarkerFile: URI, resourcesToWaitFor: URI[]): Promise<void> {
// Wait for the resources to be closed in the editor...
await this.editorService.whenClosed(resourcesToWaitFor.map(resource => ({ resource })), { waitForSaved: true });
// Wait for the resources to be closed in the text editor...
await this.instantiationService.invokeFunction(accessor => whenEditorClosed(accessor, resourcesToWaitFor));
// ...before deleting the wait marker file
await this.fileService.del(waitMarkerFile);