diff --git a/packages/ide/src/client.ts b/packages/ide/src/client.ts index d67f7a8f4..b7cfe2024 100644 --- a/packages/ide/src/client.ts +++ b/packages/ide/src/client.ts @@ -5,6 +5,7 @@ import { upload } from "./upload"; import { client } from "./fill/client"; import { clipboard } from "./fill/clipboard"; import { INotificationService, IProgressService } from "./fill/notification"; +import "./fill/os"; // Ensure it fills before anything else waiting on initData. /** * A general abstraction of an IDE client. diff --git a/packages/ide/src/fill/dialog.ts b/packages/ide/src/fill/dialog.ts index 215d5e137..1f6dd7e7b 100644 --- a/packages/ide/src/fill/dialog.ts +++ b/packages/ide/src/fill/dialog.ts @@ -78,7 +78,7 @@ export class Dialog { this.buttons = this.options.buttons.map((buttonText, buttonIndex) => { const button = document.createElement("button"); // TODO: support mnemonics. - button.innerText = buttonText.replace("_", ""); + button.innerText = buttonText.replace("&&", ""); button.addEventListener("click", () => { this.actionEmitter.emit({ buttonIndex, diff --git a/packages/ide/src/fill/electron.ts b/packages/ide/src/fill/electron.ts index c537f6c8b..d84742205 100644 --- a/packages/ide/src/fill/electron.ts +++ b/packages/ide/src/fill/electron.ts @@ -145,6 +145,14 @@ class Clipboard { return false; } + public readFindText(): string { + return ""; + } + + public writeFindText(_text: string): void { + // Nothing. + } + public writeText(value: string): Promise { return clipboard.writeText(value); } diff --git a/packages/ide/src/fill/os.ts b/packages/ide/src/fill/os.ts index 3d247b754..1966a2b64 100644 --- a/packages/ide/src/fill/os.ts +++ b/packages/ide/src/fill/os.ts @@ -1,14 +1,13 @@ -import { InitData } from "@coder/protocol"; +import { OperatingSystem, InitData } from "@coder/protocol"; import { client } from "./client"; class OS { private _homedir: string | undefined; private _tmpdir: string | undefined; + private _platform: NodeJS.Platform | undefined; public constructor() { - client.initData.then((data) => { - this.initialize(data); - }); + client.initData.then((d) => this.initialize(d)); } public homedir(): string { @@ -30,6 +29,11 @@ class OS { public initialize(data: InitData): void { this._homedir = data.homeDirectory; this._tmpdir = data.tmpDirectory; + switch (data.os) { + case OperatingSystem.Windows: this._platform = "win32"; break; + case OperatingSystem.Mac: this._platform = "darwin"; break; + default: this._platform = "linux"; break; + } } public release(): string { @@ -37,14 +41,11 @@ class OS { } public platform(): NodeJS.Platform { - if (navigator.appVersion.indexOf("Win") != -1) { - return "win32"; - } - if (navigator.appVersion.indexOf("Mac") != -1) { - return "darwin"; + if (typeof this._platform === "undefined") { + throw new Error("trying to access platform before it has been set"); } - return "linux"; + return this._platform; } } diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index 25c6ce84b..c5059c5c1 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -3336,6 +3336,13 @@ source-map@~0.1.38: dependencies: amdefine ">=0.0.4" +sourcemap-blender@1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/sourcemap-blender/-/sourcemap-blender-1.0.5.tgz#d361f3d12381c4e477178113878fdf984a91bdbc" + integrity sha512-GPhjCmDtJ8YY6zt1L6kP6WtBg6WrdWt5hw2Wmgt9rwC3yiwLo9vEuabh/YYSZ5KmFV20hVkGdkTwpXtT2E65TA== + dependencies: + source-map "^0.7.3" + split-string@^3.0.1, split-string@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" diff --git a/packages/vscode/src/client.ts b/packages/vscode/src/client.ts index a087d1988..92bce6186 100644 --- a/packages/vscode/src/client.ts +++ b/packages/vscode/src/client.ts @@ -1,216 +1,21 @@ +import { IdeClient } from "@coder/ide"; import * as paths from "./fill/paths"; -import "./fill/platform"; -import "./fill/storageDatabase"; -import "./fill/windowsService"; -import "./fill/workspacesService"; -import "./fill/environmentService"; -import "./fill/vscodeTextmate"; -import "./fill/codeEditor"; -import "./fill/mouseEvent"; -import "./fill/menuRegistry"; -import "./fill/workbenchRegistry"; -import { PasteAction } from "./fill/paste"; -import "./fill/dom"; import "./vscode.scss"; -import { IdeClient, IProgress, INotificationHandle } from "@coder/ide"; -import { registerContextMenuListener } from "vs/base/parts/contextmenu/electron-main/contextmenu"; -import { LogLevel } from "vs/platform/log/common/log"; -import { URI } from "vs/base/common/uri"; -import { INotificationService } from "vs/platform/notification/common/notification"; -import { IProgressService2, ProgressLocation } from "vs/platform/progress/common/progress"; -import { ExplorerItem, ExplorerModel } from "vs/workbench/parts/files/common/explorerModel"; -import { DragMouseEvent } from "vs/base/browser/mouseEvent"; -import { IEditorService, IResourceEditor } from "vs/workbench/services/editor/common/editorService"; -import { IEditorGroup } from "vs/workbench/services/group/common/editorGroupsService"; -import { IWindowsService, IWindowConfiguration } from "vs/platform/windows/common/windows"; -import { ServiceCollection } from "vs/platform/instantiation/common/serviceCollection"; -import { RawContextKey, IContextKeyService } from "vs/platform/contextkey/common/contextkey"; -import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from "vs/platform/workspaces/common/workspaces"; - -export class Client extends IdeClient { - private readonly windowId = parseInt(new Date().toISOString().replace(/[-:.TZ]/g, ""), 10); - private _serviceCollection: ServiceCollection | undefined; - private _clipboardContextKey: RawContextKey | undefined; - private _builtInExtensionsDirectory: string | undefined; - - public get builtInExtensionsDirectory(): string { - if (!this._builtInExtensionsDirectory) { - throw new Error("trying to access builtin extensions directory before it has been set"); - } - - return this._builtInExtensionsDirectory; - } - - public async handleExternalDrop(target: ExplorerItem | ExplorerModel, originalEvent: DragEvent): Promise { - await this.upload.uploadDropped( - originalEvent, - (target instanceof ExplorerItem ? target : target.roots[0]).resource, - ); - } - - public handleDrop(event: DragEvent, resolveTargetGroup: () => IEditorGroup, afterDrop: (targetGroup: IEditorGroup) => void, targetIndex?: number): void { - this.initData.then((d) => { - this.upload.uploadDropped(event, URI.file(d.workingDirectory)).then((paths) => { - const uris = paths.map((p) => URI.file(p)); - if (uris.length) { - (this.serviceCollection.get(IWindowsService) as IWindowsService).addRecentlyOpened(uris); - } - - const editors: IResourceEditor[] = uris.map(uri => ({ - resource: uri, - options: { - pinned: true, - index: targetIndex, - }, - })); - - const targetGroup = resolveTargetGroup(); - - (this.serviceCollection.get(IEditorService) as IEditorService).openEditors(editors, targetGroup).then(() => { - afterDrop(targetGroup); - }); - }); - }); - } - - /** - * Use to toggle the paste option inside editors based on the native clipboard. - */ - public get clipboardContextKey(): RawContextKey { - if (!this._clipboardContextKey) { - throw new Error("Trying to access clipboard context key before it has been set"); - } - - return this._clipboardContextKey; - } - - public get clipboardText(): Promise { - return this.clipboard.readText(); - } - - /** - * Create a paste action for use in text inputs. - */ - public get pasteAction(): PasteAction { - return new PasteAction(); - } - - public set workspace(ws: IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | undefined) { - if (typeof ws === "undefined") { - window.localStorage.removeItem("workspace"); - } else { - window.localStorage.setItem("workspace", JSON.stringify(ws)); - } - - location.reload(); - } - - public get workspace(): undefined | IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier { - const ws = window.localStorage.getItem("workspace"); - try { - return JSON.parse(ws!); - } catch (ex) { - return undefined; - } - } - - public get serviceCollection(): ServiceCollection { - if (!this._serviceCollection) { - throw new Error("Trying to access service collection before it has been set"); - } - - return this._serviceCollection; - } - - public set serviceCollection(collection: ServiceCollection) { - this._serviceCollection = collection; - this.progressService = { - start: (title: string, task: (progress: IProgress) => Promise, onCancel: () => void): Promise => { - let lastProgress = 0; - - return (this.serviceCollection.get(IProgressService2) as IProgressService2).withProgress({ - location: ProgressLocation.Notification, - title, - cancellable: true, - }, (progress) => { - return task({ - report: (p): void => { - progress.report({ increment: p - lastProgress }); - lastProgress = p; - }, - }); - }, () => { - onCancel(); - }); - }, - }; - - this.notificationService = { - error: (error: Error): void => (this.serviceCollection.get(INotificationService) as INotificationService).error(error), - prompt: (severity, message, buttons, onCancel): INotificationHandle => { - const handle = (this.serviceCollection.get(INotificationService) as INotificationService).prompt( - severity, message, buttons, { onCancel }, - ); - - return { - close: (): void => handle.close(), - updateMessage: (message): void => handle.updateMessage(message), - updateButtons: (buttons): void => handle.updateActions({ - primary: buttons.map((button) => ({ - id: "", - label: button.label, - tooltip: "", - class: undefined, - enabled: true, - checked: false, - radio: false, - dispose: (): void => undefined, - run: (): Promise => Promise.resolve(button.run()), - })), - }), - }; - }, - }; - } +// NOTE: shouldn't import anything from VS Code here or anything that will +// depend on a synchronous fill like `os`. +class VSClient extends IdeClient { protected initialize(): Promise { - registerContextMenuListener(); - - this._clipboardContextKey = new RawContextKey("nativeClipboard", this.clipboard.isEnabled); - return this.task("Start workbench", 1000, async (data, sharedData) => { paths._paths.initialize(data, sharedData); - this._builtInExtensionsDirectory = data.builtInExtensionsDirectory; process.env.SHELL = data.shell; - - const workspace = this.workspace || URI.file(data.workingDirectory); - const { startup } = require("./startup") as typeof import("vs/workbench/electron-browser/main"); - const config: IWindowConfiguration = { - machineId: "1", - windowId: this.windowId, - logLevel: LogLevel.Info, - mainPid: 1, - appRoot: data.dataDirectory, - execPath: data.tmpDirectory, - userEnv: {}, - nodeCachedDataDir: data.tmpDirectory, - perfEntries: [], - _: [], - }; - if ((workspace as IWorkspaceIdentifier).configPath) { - config.workspace = workspace as IWorkspaceIdentifier; - } else { - config.folderUri = workspace as URI; - } - await startup(config); - const contextKeys = this.serviceCollection.get(IContextKeyService) as IContextKeyService; - const bounded = this.clipboardContextKey.bindTo(contextKeys); - this.clipboard.onPermissionChange((enabled) => { - bounded.set(enabled); - }); - this.clipboard.initialize(); + // At this point everything should be filled, including `os`. `os` also + // relies on `initData` but it listens first so it initialize before this + // callback, meaning we are safe to include everything from VS Code now. + const { workbench } = require("./workbench") as typeof import("./workbench"); + await workbench.initialize(); }, this.initData, this.sharedProcessData); } } -export const client = new Client(); +export const client = new VSClient(); diff --git a/packages/vscode/src/fill/environmentService.ts b/packages/vscode/src/fill/environmentService.ts index b57ad0fa4..615d5b069 100644 --- a/packages/vscode/src/fill/environmentService.ts +++ b/packages/vscode/src/fill/environmentService.ts @@ -3,7 +3,7 @@ import * as environment from "vs/platform/environment/node/environmentService"; export class EnvironmentService extends environment.EnvironmentService { public get sharedIPCHandle(): string { - return paths._paths.socketPath || super.sharedIPCHandle; + return paths.getSocketPath() || super.sharedIPCHandle; } } diff --git a/packages/vscode/src/fill/labels.ts b/packages/vscode/src/fill/labels.ts new file mode 100644 index 000000000..a515cb6ee --- /dev/null +++ b/packages/vscode/src/fill/labels.ts @@ -0,0 +1,10 @@ +import * as labels from "vs/base/common/labels"; + +// Here we simply disable translation of mnemonics and leave everything as &&. +// Since we're in the browser, we can handle all platforms in the same way. +const target = labels as typeof labels; +target.mnemonicMenuLabel = (label: string, forceDisable?: boolean): string => { + return forceDisable ? label.replace(/\(&&\w\)|&&/g, "") : label; +}; +target.mnemonicButtonLabel = (label: string): string => { return label; }; +target.unmnemonicLabel = (label: string): string => { return label; }; diff --git a/packages/vscode/src/fill/paste.ts b/packages/vscode/src/fill/paste.ts index f6f5851e1..bfe7ecdfd 100644 --- a/packages/vscode/src/fill/paste.ts +++ b/packages/vscode/src/fill/paste.ts @@ -4,7 +4,7 @@ import { TERMINAL_COMMAND_ID } from "vs/workbench/parts/terminal/common/terminal import { ITerminalService } from "vs/workbench/parts/terminal/common/terminal"; import * as actions from "vs/workbench/parts/terminal/electron-browser/terminalActions"; import * as instance from "vs/workbench/parts/terminal/electron-browser/terminalInstance"; -import { clipboard } from "@coder/ide"; +import { client } from "../client"; const getLabel = (key: string, enabled: boolean): string => { return enabled @@ -18,13 +18,13 @@ export class PasteAction extends Action { public constructor() { super( "editor.action.clipboardPasteAction", - getLabel(PasteAction.KEY, clipboard.isEnabled), + getLabel(PasteAction.KEY, client.clipboard.isEnabled), undefined, - clipboard.isEnabled, - async (): Promise => clipboard.paste(), + client.clipboard.isEnabled, + async (): Promise => client.clipboard.paste(), ); - clipboard.onPermissionChange((enabled) => { + client.clipboard.onPermissionChange((enabled) => { this.label = getLabel(PasteAction.KEY, enabled); this.enabled = enabled; }); @@ -36,17 +36,17 @@ class TerminalPasteAction extends Action { public static readonly ID = TERMINAL_COMMAND_ID.PASTE; public static readonly LABEL = nls.localize("workbench.action.terminal.paste", "Paste into Active Terminal"); - public static readonly SHORT_LABEL = getLabel(TerminalPasteAction.KEY, clipboard.isEnabled); + public static readonly SHORT_LABEL = getLabel(TerminalPasteAction.KEY, client.clipboard.isEnabled); public constructor( id: string, label: string, @ITerminalService private terminalService: ITerminalService, ) { super(id, label); - clipboard.onPermissionChange((enabled) => { + client.clipboard.onPermissionChange((enabled) => { this._setLabel(getLabel(TerminalPasteAction.KEY, enabled)); }); - this._setLabel(getLabel(TerminalPasteAction.KEY, clipboard.isEnabled)); + this._setLabel(getLabel(TerminalPasteAction.KEY, client.clipboard.isEnabled)); } public run(): Promise { @@ -63,8 +63,8 @@ class TerminalPasteAction extends Action { class TerminalInstance extends instance.TerminalInstance { public async paste(): Promise { this.focus(); - if (clipboard.isEnabled) { - const text = await clipboard.readText(); + if (client.clipboard.isEnabled) { + const text = await client.clipboard.readText(); this.sendText(text, false); } else { document.execCommand("paste"); diff --git a/packages/vscode/src/fill/paths.ts b/packages/vscode/src/fill/paths.ts index eff2472aa..393d98615 100644 --- a/packages/vscode/src/fill/paths.ts +++ b/packages/vscode/src/fill/paths.ts @@ -4,6 +4,8 @@ class Paths { private _appData: string | undefined; private _defaultUserData: string | undefined; private _socketPath: string | undefined; + private _builtInExtensionsDirectory: string | undefined; + private _workingDirectory: string | undefined; public get appData(): string { if (typeof this._appData === "undefined") { @@ -29,14 +31,35 @@ class Paths { return this._socketPath; } + public get builtInExtensionsDirectory(): string { + if (!this._builtInExtensionsDirectory) { + throw new Error("trying to access builtin extensions directory before it has been set"); + } + + return this._builtInExtensionsDirectory; + } + + public get workingDirectory(): string { + if (!this._workingDirectory) { + throw new Error("trying to access working directory before it has been set"); + } + + return this._workingDirectory; + } + public initialize(data: InitData, sharedData: SharedProcessData): void { process.env.VSCODE_LOGS = sharedData.logPath; this._appData = data.dataDirectory; this._defaultUserData = data.dataDirectory; this._socketPath = sharedData.socketPath; + this._builtInExtensionsDirectory = data.builtInExtensionsDirectory; + this._workingDirectory = data.workingDirectory; } } export const _paths = new Paths(); export const getAppDataPath = (): string => _paths.appData; export const getDefaultUserDataPath = (): string => _paths.defaultUserData; +export const getWorkingDirectory = (): string => _paths.workingDirectory; +export const getBuiltInExtensionsDirectory = (): string => _paths.builtInExtensionsDirectory; +export const getSocketPath = (): string => _paths.socketPath; diff --git a/packages/vscode/src/fill/platform.ts b/packages/vscode/src/fill/platform.ts index 2d8fb863a..d0fa1d66a 100644 --- a/packages/vscode/src/fill/platform.ts +++ b/packages/vscode/src/fill/platform.ts @@ -1,12 +1,25 @@ +import * as os from "os"; import * as platform from "vs/base/common/platform"; +// tslint:disable no-any to override const + // Use en instead of en-US since that's vscode default and it uses // that to determine whether to output aliases which will be redundant. if (platform.locale === "en-US") { - // tslint:disable-next-line no-any to override const (platform as any).locale = "en"; } if (platform.language === "en-US") { - // tslint:disable-next-line no-any to override const (platform as any).language = "en"; } + +// Use the server's platform instead of the client's. For example, this affects +// how VS Code handles paths (and more) because different platforms give +// different results. We'll have to counter for things that shouldn't change, +// like keybindings. +(platform as any).isLinux = os.platform() === "linux"; +(platform as any).isWindows = os.platform() === "win32"; +(platform as any).isMacintosh = os.platform() === "darwin"; + +// This is used for keybindings, and in one place to choose between \r\n and \n +// (which we change to use platform.isWindows instead). +(platform as any).OS = (platform.isMacintosh ? platform.OperatingSystem.Macintosh : (platform.isWindows ? platform.OperatingSystem.Windows : platform.OperatingSystem.Linux)); diff --git a/packages/vscode/src/fill/storageDatabase.ts b/packages/vscode/src/fill/storageDatabase.ts index 547f140f5..d47a47b13 100644 --- a/packages/vscode/src/fill/storageDatabase.ts +++ b/packages/vscode/src/fill/storageDatabase.ts @@ -2,13 +2,13 @@ import { readFile, writeFile, mkdir } from "fs"; import * as path from "path"; import { promisify } from "util"; import { IDisposable } from "@coder/disposable"; +import { logger, field } from "@coder/logger"; import { Event } from "vs/base/common/event"; import * as workspaceStorage from "vs/base/node/storage"; import * as globalStorage from "vs/platform/storage/node/storageIpc"; -import * as paths from "./paths"; -import { logger, field } from "@coder/logger"; -import { client } from "@coder/vscode/src/client"; import { IStorageService, WillSaveStateReason } from "vs/platform/storage/common/storage"; +import * as paths from "./paths"; +import { workbench } from "../workbench"; class StorageDatabase implements workspaceStorage.IStorageDatabase { public readonly onDidChangeItemsExternal = Event.None; @@ -80,7 +80,7 @@ class StorageDatabase implements workspaceStorage.IStorageDatabase { private triggerFlush(reason: WillSaveStateReason = WillSaveStateReason.NONE): boolean { // tslint:disable-next-line:no-any - const storageService = client.serviceCollection.get(IStorageService) as any; + const storageService = workbench.serviceCollection.get(IStorageService) as any; if (reason === WillSaveStateReason.SHUTDOWN && storageService.close) { storageService.close(); diff --git a/packages/vscode/src/fill/windowsService.ts b/packages/vscode/src/fill/windowsService.ts index 04d545a72..15cdc3305 100644 --- a/packages/vscode/src/fill/windowsService.ts +++ b/packages/vscode/src/fill/windowsService.ts @@ -9,6 +9,7 @@ import { IRecentlyOpened } from "vs/platform/history/common/history"; import { ISerializableCommandAction } from "vs/platform/actions/common/actions"; import { client } from "../client"; import { showOpenDialog } from "../dialog"; +import { workbench } from "../workbench"; /** * Instead of going to the shared process, we'll directly run these methods on @@ -79,7 +80,7 @@ class WindowsService implements IWindowsService { openDirectory: true, }, }).then((path) => { - client.workspace = URI.file(path); + workbench.workspace = URI.file(path); }).catch((ex) => { // }); @@ -150,12 +151,12 @@ class WindowsService implements IWindowsService { public enterWorkspace(_windowId: number, _path: URI): Promise { if (_path.path.endsWith(".json")) { - client.workspace = { + workbench.workspace = { id: "Untitled", configPath: _path.path, }; } else { - client.workspace = _path; + workbench.workspace = _path; } return undefined!; diff --git a/packages/vscode/src/fill/workbenchRegistry.ts b/packages/vscode/src/fill/workbenchRegistry.ts index c0a5af9a9..4351a92be 100644 --- a/packages/vscode/src/fill/workbenchRegistry.ts +++ b/packages/vscode/src/fill/workbenchRegistry.ts @@ -8,7 +8,7 @@ import { ToggleDevToolsAction } from "vs/workbench/electron-browser/actions/deve import { TerminalPasteAction } from "vs/workbench/parts/terminal/electron-browser/terminalActions"; import { KEYBINDING_CONTEXT_TERMINAL_FOCUS } from "vs/workbench/parts/terminal/common/terminal"; import { KeyCode, KeyMod } from "vs/base/common/keyCodes"; -import { client } from "../client"; +import { workbench } from "../workbench"; // Intercept adding workbench actions so we can skip actions that won't work or // modify actions that need different conditions, keybindings, etc. @@ -32,7 +32,7 @@ registry.registerWorkbenchAction = (descriptor: SyncActionDescriptor, alias: str mac: { primary: 0 }, }; // tslint:disable-next-line no-any override private - (descriptor as any)._keybindingContext = ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_FOCUS, client.clipboardContextKey); + (descriptor as any)._keybindingContext = ContextKeyExpr.and(KEYBINDING_CONTEXT_TERMINAL_FOCUS, workbench.clipboardContextKey); } return originalRegister(descriptor, alias, category, when); diff --git a/packages/vscode/src/fill/workspacesService.ts b/packages/vscode/src/fill/workspacesService.ts index 904d2686f..3456aab54 100644 --- a/packages/vscode/src/fill/workspacesService.ts +++ b/packages/vscode/src/fill/workspacesService.ts @@ -4,7 +4,7 @@ import { ILogService } from "vs/platform/log/common/log"; import { IWorkspaceFolderCreationData, IWorkspaceIdentifier, IWorkspacesService } from "vs/platform/workspaces/common/workspaces"; import { WorkspacesMainService } from "vs/platform/workspaces/electron-main/workspacesMainService"; import * as workspacesIpc from "vs/platform/workspaces/node/workspacesIpc"; -import { client } from "../client"; +import { workbench } from "../workbench"; /** * Instead of going to the shared process, we'll directly run these methods on @@ -16,8 +16,8 @@ class WorkspacesService implements IWorkspacesService { public createUntitledWorkspace(folders?: IWorkspaceFolderCreationData[] | undefined): Promise { const mainService = new WorkspacesMainService( - client.serviceCollection.get(IEnvironmentService) as IEnvironmentService, - client.serviceCollection.get(ILogService) as ILogService, + workbench.serviceCollection.get(IEnvironmentService) as IEnvironmentService, + workbench.serviceCollection.get(ILogService) as ILogService, ); // lib/vscode/src/vs/platform/workspaces/node/workspacesIpc.ts diff --git a/packages/vscode/src/startup.ts b/packages/vscode/src/startup.ts deleted file mode 100644 index e088b2954..000000000 --- a/packages/vscode/src/startup.ts +++ /dev/null @@ -1,183 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import "vs/loader"; - -//#region --- workbench/editor core - -import "vs/editor/editor.all"; - -import "vs/workbench/api/electron-browser/extensionHost.contribution"; - -import "vs/workbench/electron-browser/shell.contribution"; -import "vs/workbench/browser/workbench.contribution"; - -import { startup } from "vs/workbench/electron-browser/main"; - -//#endregion - -//#region --- workbench actions - -import "vs/workbench/browser/actions/layoutActions"; -import "vs/workbench/browser/actions/listCommands"; -import "vs/workbench/browser/actions/navigationActions"; -import "vs/workbench/browser/parts/quickopen/quickOpenActions"; -import "vs/workbench/browser/parts/quickinput/quickInputActions"; - -//#endregion - -//#region --- API Extension Points - -import "vs/workbench/api/common/menusExtensionPoint"; -import "vs/workbench/api/common/configurationExtensionPoint"; -import "vs/workbench/api/browser/viewsExtensionPoint"; - -//#endregion - -//#region --- workbench services - -import "vs/workbench/services/bulkEdit/electron-browser/bulkEditService"; - -//#endregion - -//#region --- workbench parts - -// Localizations -import "vs/workbench/parts/localizations/electron-browser/localizations.contribution"; - -// Preferences -import "vs/workbench/parts/preferences/electron-browser/preferences.contribution"; -import "vs/workbench/parts/preferences/browser/keybindingsEditorContribution"; - -// Logs -import "vs/workbench/parts/logs/electron-browser/logs.contribution"; - -// Quick Open Handlers -import "vs/workbench/parts/quickopen/browser/quickopen.contribution"; - -// Explorer -import "vs/workbench/parts/files/electron-browser/explorerViewlet"; -import "vs/workbench/parts/files/electron-browser/fileActions.contribution"; -import "vs/workbench/parts/files/electron-browser/files.contribution"; - -// Backup -import "vs/workbench/parts/backup/common/backup.contribution"; - -// Stats -import "vs/workbench/parts/stats/node/stats.contribution"; - -// Rapid Render Splash -import "vs/workbench/parts/splash/electron-browser/partsSplash.contribution"; - -// Search -import "vs/workbench/parts/search/electron-browser/search.contribution"; -import "vs/workbench/parts/search/browser/searchView"; -import "vs/workbench/parts/search/browser/openAnythingHandler"; - -// SCM -import "vs/workbench/parts/scm/electron-browser/scm.contribution"; -import "vs/workbench/parts/scm/electron-browser/scmViewlet"; - -// Debug -import "vs/workbench/parts/debug/electron-browser/debug.contribution"; -import "vs/workbench/parts/debug/browser/debugQuickOpen"; -import "vs/workbench/parts/debug/electron-browser/repl"; -import "vs/workbench/parts/debug/browser/debugViewlet"; - -// Markers -import "vs/workbench/parts/markers/electron-browser/markers.contribution"; - -// Comments -import "vs/workbench/parts/comments/electron-browser/comments.contribution"; - -// HTML Preview -import "vs/workbench/parts/html/electron-browser/html.contribution"; - -// URL Support -import "vs/workbench/parts/url/electron-browser/url.contribution"; - -// Webview -import "vs/workbench/parts/webview/electron-browser/webview.contribution"; - -// Extensions Management -import "vs/workbench/parts/extensions/electron-browser/extensions.contribution"; -import "vs/workbench/parts/extensions/browser/extensionsQuickOpen"; -import "vs/workbench/parts/extensions/electron-browser/extensionsViewlet"; - -// Output Panel -import "vs/workbench/parts/output/electron-browser/output.contribution"; -import "vs/workbench/parts/output/browser/outputPanel"; - -// Terminal -import "vs/workbench/parts/terminal/electron-browser/terminal.contribution"; -import "vs/workbench/parts/terminal/browser/terminalQuickOpen"; -import "vs/workbench/parts/terminal/electron-browser/terminalPanel"; - -// Relauncher -import "vs/workbench/parts/relauncher/electron-browser/relauncher.contribution"; - -// Tasks -import "vs/workbench/parts/tasks/electron-browser/task.contribution"; - -// Emmet -import "vs/workbench/parts/emmet/browser/emmet.browser.contribution"; -import "vs/workbench/parts/emmet/electron-browser/emmet.contribution"; - -// CodeEditor Contributions -import "vs/workbench/parts/codeEditor/electron-browser/codeEditor.contribution"; - -// Execution -import "vs/workbench/parts/execution/electron-browser/execution.contribution"; - -// Snippets -import "vs/workbench/parts/snippets/electron-browser/snippets.contribution"; -import "vs/workbench/parts/snippets/electron-browser/snippetsService"; -import "vs/workbench/parts/snippets/electron-browser/insertSnippet"; -import "vs/workbench/parts/snippets/electron-browser/configureSnippets"; -import "vs/workbench/parts/snippets/electron-browser/tabCompletion"; - -// Send a Smile -import "vs/workbench/parts/feedback/electron-browser/feedback.contribution"; - -// Update -import "vs/workbench/parts/update/electron-browser/update.contribution"; - -// Surveys -import "vs/workbench/parts/surveys/electron-browser/nps.contribution"; -import "vs/workbench/parts/surveys/electron-browser/languageSurveys.contribution"; - -// Performance -import "vs/workbench/parts/performance/electron-browser/performance.contribution"; - -// CLI -import "vs/workbench/parts/cli/electron-browser/cli.contribution"; - -// Themes Support -import "vs/workbench/parts/themes/electron-browser/themes.contribution"; -import "vs/workbench/parts/themes/test/electron-browser/themes.test.contribution"; - -// Watermark -import "vs/workbench/parts/watermark/electron-browser/watermark"; - -// Welcome -import "vs/workbench/parts/welcome/walkThrough/electron-browser/walkThrough.contribution"; -import "vs/workbench/parts/welcome/gettingStarted/electron-browser/gettingStarted.contribution"; -import "vs/workbench/parts/welcome/overlay/browser/welcomeOverlay"; -import "vs/workbench/parts/welcome/page/electron-browser/welcomePage.contribution"; - -// Outline -import "vs/workbench/parts/outline/electron-browser/outline.contribution"; - -// Experiments -import "vs/workbench/parts/experiments/electron-browser/experiments.contribution"; - -//#endregion - -import { URI } from "vs/base/common/uri"; - -export { - URI, - startup, -}; diff --git a/packages/vscode/src/workbench.ts b/packages/vscode/src/workbench.ts new file mode 100644 index 000000000..5929d8967 --- /dev/null +++ b/packages/vscode/src/workbench.ts @@ -0,0 +1,204 @@ +import * as os from "os"; +import { IProgress, INotificationHandle } from "@coder/ide"; +import { client } from "./client"; + +import "./fill/platform"; +import "./fill/dom"; +import "./fill/codeEditor"; +import "./fill/environmentService"; +import "./fill/labels"; +import "./fill/menuRegistry"; +import "./fill/mouseEvent"; +import "./fill/storageDatabase"; +import "./fill/vscodeTextmate"; +import "./fill/windowsService"; +import "./fill/workbenchRegistry"; +import "./fill/workspacesService"; +import * as paths from "./fill/paths"; +import { PasteAction } from "./fill/paste"; + +import { ExplorerItem, ExplorerModel } from "vs/workbench/parts/files/common/explorerModel"; +import { IEditorGroup } from "vs/workbench/services/group/common/editorGroupsService"; +import { IEditorService, IResourceEditor } from "vs/workbench/services/editor/common/editorService"; +import { INotificationService } from "vs/platform/notification/common/notification"; +import { IProgressService2, ProgressLocation } from "vs/platform/progress/common/progress"; +import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from "vs/platform/workspaces/common/workspaces"; +import { IWindowsService, IWindowConfiguration } from "vs/platform/windows/common/windows"; +import { LogLevel } from "vs/platform/log/common/log"; +import { RawContextKey, IContextKeyService } from "vs/platform/contextkey/common/contextkey"; +import { ServiceCollection } from "vs/platform/instantiation/common/serviceCollection"; +import { URI } from "vs/base/common/uri"; + +import "vs/loader"; + +export class Workbench { + private readonly windowId = parseInt(new Date().toISOString().replace(/[-:.TZ]/g, ""), 10); + private _serviceCollection: ServiceCollection | undefined; + private _clipboardContextKey: RawContextKey | undefined; + + public async handleExternalDrop(target: ExplorerItem | ExplorerModel, originalEvent: DragEvent): Promise { + await client.upload.uploadDropped( + originalEvent, + (target instanceof ExplorerItem ? target : target.roots[0]).resource, + ); + } + + public handleDrop(event: DragEvent, resolveTargetGroup: () => IEditorGroup, afterDrop: (targetGroup: IEditorGroup) => void, targetIndex?: number): void { + client.upload.uploadDropped(event, URI.file(paths.getWorkingDirectory())).then((paths) => { + const uris = paths.map((p) => URI.file(p)); + if (uris.length) { + (this.serviceCollection.get(IWindowsService) as IWindowsService).addRecentlyOpened(uris); + } + + const editors: IResourceEditor[] = uris.map(uri => ({ + resource: uri, + options: { + pinned: true, + index: targetIndex, + }, + })); + + const targetGroup = resolveTargetGroup(); + + (this.serviceCollection.get(IEditorService) as IEditorService).openEditors(editors, targetGroup).then(() => { + afterDrop(targetGroup); + }); + }); + } + + /** + * Use to toggle the paste option inside editors based on the native clipboard. + */ + public get clipboardContextKey(): RawContextKey { + if (!this._clipboardContextKey) { + throw new Error("Trying to access clipboard context key before it has been set"); + } + + return this._clipboardContextKey; + } + + public get clipboardText(): Promise { + return client.clipboard.readText(); + } + + /** + * Create a paste action for use in text inputs. + */ + public get pasteAction(): PasteAction { + return new PasteAction(); + } + + public set workspace(ws: IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | undefined) { + if (typeof ws === "undefined") { + window.localStorage.removeItem("workspace"); + } else { + window.localStorage.setItem("workspace", JSON.stringify(ws)); + } + + location.reload(); + } + + public get workspace(): undefined | IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier { + const ws = window.localStorage.getItem("workspace"); + try { + return JSON.parse(ws!); + } catch (ex) { + return undefined; + } + } + + public get serviceCollection(): ServiceCollection { + if (!this._serviceCollection) { + throw new Error("Trying to access service collection before it has been set"); + } + + return this._serviceCollection; + } + + public set serviceCollection(collection: ServiceCollection) { + this._serviceCollection = collection; + client.progressService = { + start: (title: string, task: (progress: IProgress) => Promise, onCancel: () => void): Promise => { + let lastProgress = 0; + + return (this.serviceCollection.get(IProgressService2) as IProgressService2).withProgress({ + location: ProgressLocation.Notification, + title, + cancellable: true, + }, (progress) => { + return task({ + report: (p): void => { + progress.report({ increment: p - lastProgress }); + lastProgress = p; + }, + }); + }, () => { + onCancel(); + }); + }, + }; + + client.notificationService = { + error: (error: Error): void => (this.serviceCollection.get(INotificationService) as INotificationService).error(error), + prompt: (severity, message, buttons, onCancel): INotificationHandle => { + const handle = (this.serviceCollection.get(INotificationService) as INotificationService).prompt( + severity, message, buttons, { onCancel }, + ); + + return { + close: (): void => handle.close(), + updateMessage: (message): void => handle.updateMessage(message), + updateButtons: (buttons): void => handle.updateActions({ + primary: buttons.map((button) => ({ + id: "", + label: button.label, + tooltip: "", + class: undefined, + enabled: true, + checked: false, + radio: false, + dispose: (): void => undefined, + run: (): Promise => Promise.resolve(button.run()), + })), + }), + }; + }, + }; + } + + public async initialize(): Promise { + this._clipboardContextKey = new RawContextKey("nativeClipboard", client.clipboard.isEnabled); + + const workspace = this.workspace || URI.file(paths.getWorkingDirectory()); + // If we try to import this above, workbench will be undefined due to + // circular imports. + require("vs/workbench/workbench.main"); + const { startup } = require("vs/workbench/electron-browser/main"); + const config: IWindowConfiguration = { + machineId: "1", + windowId: this.windowId, + logLevel: LogLevel.Info, + mainPid: 1, + appRoot: paths.getDefaultUserDataPath(), + execPath: os.tmpdir(), + userEnv: {}, + nodeCachedDataDir: os.tmpdir(), + perfEntries: [], + _: [], + }; + if ((workspace as IWorkspaceIdentifier).configPath) { + config.workspace = workspace as IWorkspaceIdentifier; + } else { + config.folderUri = workspace as URI; + } + await startup(config); + const contextKeys = this.serviceCollection.get(IContextKeyService) as IContextKeyService; + const bounded = this.clipboardContextKey.bindTo(contextKeys); + client.clipboard.onPermissionChange((enabled) => { + bounded.set(enabled); + }); + client.clipboard.initialize(); + } +} + +export const workbench = new Workbench(); diff --git a/scripts/vscode.patch b/scripts/vscode.patch index 6f2fa8e0c..4e3c6d719 100644 --- a/scripts/vscode.patch +++ b/scripts/vscode.patch @@ -1,3 +1,141 @@ +diff --git a/src/vs/base/browser/browser.ts b/src/vs/base/browser/browser.ts +index 639ac3d031..85999db640 100644 +--- a/src/vs/base/browser/browser.ts ++++ b/src/vs/base/browser/browser.ts +@@ -153,0 +154,4 @@ export const isEdgeWebView = isEdge && (userAgent.indexOf('WebView/') >= 0); ++export const isMacintosh = userAgent.indexOf("Macintosh") >= 0; ++export const isWindows = userAgent.indexOf("Windows") >= 0; ++export const isLinux = userAgent.indexOf("Linux") >= 0; ++ +diff --git a/src/vs/base/browser/keyboardEvent.ts b/src/vs/base/browser/keyboardEvent.ts +index a6fdce5c7c..7a80c85398 100644 +--- a/src/vs/base/browser/keyboardEvent.ts ++++ b/src/vs/base/browser/keyboardEvent.ts +@@ -154 +154 @@ let INVERSE_KEY_CODE_MAP: KeyCode[] = new Array(KeyCode.MAX_VALUE); +- if (platform.isMacintosh) { ++ if (browser.isMacintosh) { +@@ -159 +159 @@ let INVERSE_KEY_CODE_MAP: KeyCode[] = new Array(KeyCode.MAX_VALUE); +- if (platform.isMacintosh) { ++ if (browser.isMacintosh) { +@@ -202 +202 @@ export interface IKeyboardEvent { +-const ctrlKeyMod = (platform.isMacintosh ? KeyMod.WinCtrl : KeyMod.CtrlCmd); ++const ctrlKeyMod = (browser.isMacintosh ? KeyMod.WinCtrl : KeyMod.CtrlCmd); +@@ -205 +205 @@ const shiftKeyMod = KeyMod.Shift; +-const metaKeyMod = (platform.isMacintosh ? KeyMod.CtrlCmd : KeyMod.WinCtrl); ++const metaKeyMod = (browser.isMacintosh ? KeyMod.CtrlCmd : KeyMod.WinCtrl); +diff --git a/src/vs/base/browser/ui/aria/aria.ts b/src/vs/base/browser/ui/aria/aria.ts +index 1922450144..9900776aa2 100644 +--- a/src/vs/base/browser/ui/aria/aria.ts ++++ b/src/vs/base/browser/ui/aria/aria.ts +@@ -8 +8 @@ import * as nls from 'vs/nls'; +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/base/browser/ui/list/listWidget.ts b/src/vs/base/browser/ui/list/listWidget.ts +index 5386958054..5c936e0a1d 100644 +--- a/src/vs/base/browser/ui/list/listWidget.ts ++++ b/src/vs/base/browser/ui/list/listWidget.ts +@@ -13 +13 @@ import * as DOM from 'vs/base/browser/dom'; +-import * as platform from 'vs/base/common/platform'; ++import * as browser from 'vs/base/browser/browser'; +@@ -257 +257 @@ class KeyboardController implements IDisposable { +- onKeyDown.filter(e => (platform.isMacintosh ? e.metaKey : e.ctrlKey) && e.keyCode === KeyCode.KEY_A).on(this.onCtrlA, this, this.disposables); ++ onKeyDown.filter(e => (browser.isMacintosh ? e.metaKey : e.ctrlKey) && e.keyCode === KeyCode.KEY_A).on(this.onCtrlA, this, this.disposables); +@@ -479 +479 @@ export function isSelectionSingleChangeEvent(event: IListMouseEvent | IList +- return platform.isMacintosh ? event.browserEvent.metaKey : event.browserEvent.ctrlKey; ++ return browser.isMacintosh ? event.browserEvent.metaKey : event.browserEvent.ctrlKey; +@@ -539 +539 @@ class MouseController implements IDisposable { +- return platform.isMacintosh ? event.browserEvent.metaKey : event.browserEvent.ctrlKey; ++ return browser.isMacintosh ? event.browserEvent.metaKey : event.browserEvent.ctrlKey; +diff --git a/src/vs/base/browser/ui/sash/sash.ts b/src/vs/base/browser/ui/sash/sash.ts +index 8c7168bad5..8bbea63b3b 100644 +--- a/src/vs/base/browser/ui/sash/sash.ts ++++ b/src/vs/base/browser/ui/sash/sash.ts +@@ -9 +9 @@ import { isIPad } from 'vs/base/browser/browser'; +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/base/browser/ui/scrollbar/scrollableElement.ts b/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +index 9b31c847f7..51de0eaf2f 100644 +--- a/src/vs/base/browser/ui/scrollbar/scrollableElement.ts ++++ b/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +@@ -18 +18 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle'; +-import * as platform from 'vs/base/common/platform'; ++import * as browser from 'vs/base/browser/browser'; +@@ -269 +269 @@ export abstract class AbstractScrollableElement extends Widget { +- if (platform.isMacintosh) { ++ if (browser.isMacintosh) { +@@ -338 +338 @@ export abstract class AbstractScrollableElement extends Widget { +- const shiftConvert = !platform.isMacintosh && e.browserEvent && e.browserEvent.shiftKey; ++ const shiftConvert = !browser.isMacintosh && e.browserEvent && e.browserEvent.shiftKey; +@@ -571 +571 @@ function resolveOptions(opts: ScrollableElementCreationOptions): ScrollableEleme +- if (platform.isMacintosh) { ++ if (browser.isMacintosh) { +diff --git a/src/vs/base/browser/ui/selectBox/selectBox.ts b/src/vs/base/browser/ui/selectBox/selectBox.ts +index 0e7314fd28..814fb0abd8 100644 +--- a/src/vs/base/browser/ui/selectBox/selectBox.ts ++++ b/src/vs/base/browser/ui/selectBox/selectBox.ts +@@ -16 +16 @@ import { SelectBoxList } from 'vs/base/browser/ui/selectBox/selectBoxCustom'; +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/base/browser/ui/selectBox/selectBoxCustom.ts b/src/vs/base/browser/ui/selectBox/selectBoxCustom.ts +index 77ca7e4f06..2dc4bf24f6 100644 +--- a/src/vs/base/browser/ui/selectBox/selectBoxCustom.ts ++++ b/src/vs/base/browser/ui/selectBox/selectBoxCustom.ts +@@ -20 +20 @@ import { ISelectBoxDelegate, ISelectOptionItem, ISelectBoxOptions, ISelectBoxSty +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/base/browser/ui/selectBox/selectBoxNative.ts b/src/vs/base/browser/ui/selectBox/selectBoxNative.ts +index 01f59d40fa..453d5c4ed3 100644 +--- a/src/vs/base/browser/ui/selectBox/selectBoxNative.ts ++++ b/src/vs/base/browser/ui/selectBox/selectBoxNative.ts +@@ -12 +12 @@ import { ISelectBoxDelegate, ISelectOptionItem, ISelectBoxOptions, ISelectBoxSty +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/base/browser/ui/tree/abstractTree.ts b/src/vs/base/browser/ui/tree/abstractTree.ts +index 742c6aa0d8..2791d0691e 100644 +--- a/src/vs/base/browser/ui/tree/abstractTree.ts ++++ b/src/vs/base/browser/ui/tree/abstractTree.ts +@@ -24 +24 @@ import { disposableTimeout } from 'vs/base/common/async'; +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts b/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts +index 65cdc14af5..f3567da05d 100644 +--- a/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts ++++ b/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts +@@ -8 +8 @@ import * as nls from 'vs/nls'; +-import * as platform from 'vs/base/common/platform'; ++import * as browser from 'vs/base/browser/browser'; +@@ -66 +66 @@ export class QuickOpenController extends DefaultController { +- if (platform.isMacintosh) { ++ if (browser.isMacintosh) { +diff --git a/src/vs/base/parts/tree/browser/treeDefaults.ts b/src/vs/base/parts/tree/browser/treeDefaults.ts +index 8d30a79e50..30cb97a224 100644 +--- a/src/vs/base/parts/tree/browser/treeDefaults.ts ++++ b/src/vs/base/parts/tree/browser/treeDefaults.ts +@@ -8,0 +9 @@ import * as platform from 'vs/base/common/platform'; ++import * as browser from 'vs/base/browser/browser'; +@@ -111 +112 @@ export class DefaultController implements _.IController { +- if (platform.isMacintosh) { ++ if (browser.isMacintosh) { +@@ -153 +154 @@ export class DefaultController implements _.IController { +- const isMac = platform.isMacintosh; ++ const isMac = browser.isMacintosh; +diff --git a/src/vs/code/electron-browser/issue/issueReporterMain.ts b/src/vs/code/electron-browser/issue/issueReporterMain.ts +index 169de560b5..1b79b77040 100644 +--- a/src/vs/code/electron-browser/issue/issueReporterMain.ts ++++ b/src/vs/code/electron-browser/issue/issueReporterMain.ts +@@ -405 +405 @@ export class IssueReporter extends Disposable { +- const cmdOrCtrlKey = platform.isMacintosh ? e.metaKey : e.ctrlKey; ++ const cmdOrCtrlKey = browser.isMacintosh ? e.metaKey : e.ctrlKey; +@@ -439 +439 @@ export class IssueReporter extends Disposable { +- if (platform.isMacintosh) { ++ if (browser.isMacintosh) { +diff --git a/src/vs/code/electron-browser/processExplorer/processExplorerMain.ts b/src/vs/code/electron-browser/processExplorer/processExplorerMain.ts +index a9e8f38c81..0c305e4c1a 100644 +--- a/src/vs/code/electron-browser/processExplorer/processExplorerMain.ts ++++ b/src/vs/code/electron-browser/processExplorer/processExplorerMain.ts +@@ -304 +304 @@ export function startup(data: ProcessExplorerData): void { +- const cmdOrCtrlKey = platform.isMacintosh ? e.metaKey : e.ctrlKey; ++ const cmdOrCtrlKey = browser.isMacintosh ? e.metaKey : e.ctrlKey; diff --git a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts b/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts index a342222d04..c731e82591 100644 --- a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts @@ -5,8 +143,68 @@ index a342222d04..c731e82591 100644 @@ -195,0 +196,2 @@ async function handshake(configuration: ISharedProcessConfiguration): Promise { + if (editor instanceof (require('vs/editor/browser/widget/codeEditorWidget') as typeof import('vs/editor/browser/widget/codeEditorWidget')).CodeEditorWidget) { + try { + editor.trigger('', (require('vs/editor/common/editorCommon') as typeof import ('vs/editor/common/editorCommon')).Handler.Paste, { -+ text: await (require('vs/../../../../packages/vscode') as typeof import ('vs/../../../../packages/vscode')).client.clipboardText, ++ text: await (require('vs/../../../../packages/vscode/src/workbench') as typeof import ('vs/../../../../packages/vscode/src/workbench')).workbench.clipboardText, + }); + } catch (ex) { + super.run(accessor, editor); @@ -37,6 +235,52 @@ index 5e43f1b39e..a008d3ac7e 100644 + super.run(accessor, editor); + } + } +diff --git a/src/vs/editor/contrib/dnd/dnd.ts b/src/vs/editor/contrib/dnd/dnd.ts +index caa3ea75fd..e32371f932 100644 +--- a/src/vs/editor/contrib/dnd/dnd.ts ++++ b/src/vs/editor/contrib/dnd/dnd.ts +@@ -9 +9 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle'; +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/editor/contrib/goToDefinition/clickLinkGesture.ts b/src/vs/editor/contrib/goToDefinition/clickLinkGesture.ts +index 3b72a01a35..0d723f5800 100644 +--- a/src/vs/editor/contrib/goToDefinition/clickLinkGesture.ts ++++ b/src/vs/editor/contrib/goToDefinition/clickLinkGesture.ts +@@ -86 +86 @@ function createOptions(multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey'): C +- if (platform.isMacintosh) { ++ if (browser.isMacintosh) { +@@ -92 +92 @@ function createOptions(multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey'): C +- if (platform.isMacintosh) { ++ if (browser.isMacintosh) { +diff --git a/src/vs/editor/contrib/links/links.ts b/src/vs/editor/contrib/links/links.ts +index d224f2254a..4baf574025 100644 +--- a/src/vs/editor/contrib/links/links.ts ++++ b/src/vs/editor/contrib/links/links.ts +@@ -13 +13 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle'; +-import * as platform from 'vs/base/common/platform'; ++import * as browser from 'vs/base/browser/browser'; +@@ -29 +29 @@ const HOVER_MESSAGE_GENERAL_META = new MarkdownString().appendText( +- platform.isMacintosh ++ browser.isMacintosh +@@ -35 +35 @@ const HOVER_MESSAGE_COMMAND_META = new MarkdownString().appendText( +- platform.isMacintosh ++ browser.isMacintosh +@@ -41 +41 @@ const HOVER_MESSAGE_GENERAL_ALT = new MarkdownString().appendText( +- platform.isMacintosh ++ browser.isMacintosh +@@ -47 +47 @@ const HOVER_MESSAGE_COMMAND_ALT = new MarkdownString().appendText( +- platform.isMacintosh ++ browser.isMacintosh +diff --git a/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts b/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts +index 605c1209e1..e8131513de 100644 +--- a/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts ++++ b/src/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.ts +@@ -261 +261 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { +- platform.isMacintosh ++ browser.isMacintosh +@@ -290 +290 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { +- platform.isMacintosh ++ browser.isMacintosh diff --git a/src/vs/loader.js b/src/vs/loader.js index 4eddcab3a0..5d80768406 100644 --- a/src/vs/loader.js @@ -61,6 +305,36 @@ index 4eddcab3a0..5d80768406 100644 @@ -741 +748 @@ var AMDLoader; - moduleExports_1 = nodeRequire(pieces[1]); + moduleExports_1 = context(pieces[1]); +diff --git a/src/vs/platform/clipboard/electron-browser/clipboardService.ts b/src/vs/platform/clipboard/electron-browser/clipboardService.ts +index 667b47218a..36dd5ddd3e 100644 +--- a/src/vs/platform/clipboard/electron-browser/clipboardService.ts ++++ b/src/vs/platform/clipboard/electron-browser/clipboardService.ts +@@ -9 +9 @@ import { URI } from 'vs/base/common/uri'; +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/platform/launch/electron-main/launchService.ts b/src/vs/platform/launch/electron-main/launchService.ts +index ba14b19533..d1590f50ef 100644 +--- a/src/vs/platform/launch/electron-main/launchService.ts ++++ b/src/vs/platform/launch/electron-main/launchService.ts +@@ -9 +9,2 @@ import { IURLService } from 'vs/platform/url/common/url'; +-import { IProcessEnvironment, isMacintosh } from 'vs/base/common/platform'; ++import { IProcessEnvironment } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/platform/windows/common/windows.ts b/src/vs/platform/windows/common/windows.ts +index 56eaeef6f4..ec8a6e5960 100644 +--- a/src/vs/platform/windows/common/windows.ts ++++ b/src/vs/platform/windows/common/windows.ts +@@ -9 +9,2 @@ import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry'; +-import { IProcessEnvironment, isMacintosh } from 'vs/base/common/platform'; ++import { IProcessEnvironment } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/platform/workbench/common/contextkeys.ts b/src/vs/platform/workbench/common/contextkeys.ts +index 94b03a0ce9..c3608a2763 100644 +--- a/src/vs/platform/workbench/common/contextkeys.ts ++++ b/src/vs/platform/workbench/common/contextkeys.ts +@@ -7 +7 @@ import { RawContextKey } from 'vs/platform/contextkey/common/contextkey'; +-import { isMacintosh, isLinux, isWindows } from 'vs/base/common/platform'; ++import { isMacintosh, isLinux, isWindows } from 'vs/base/browser/browser'; diff --git a/src/vs/workbench/api/electron-browser/mainThreadHeapService.ts b/src/vs/workbench/api/electron-browser/mainThreadHeapService.ts index 6c52cbc937..09adbe7f51 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadHeapService.ts @@ -77,12 +351,143 @@ index 1f4a1e100b..1bf605a064 100644 - r = require.__$__nodeRequire(modulePath); + r = (global as any).nativeNodeRequire(modulePath); diff --git a/src/vs/workbench/browser/dnd.ts b/src/vs/workbench/browser/dnd.ts -index e73acff052..bd65fcbd6c 100644 +index e73acff052..c52bb3c7a2 100644 --- a/src/vs/workbench/browser/dnd.ts +++ b/src/vs/workbench/browser/dnd.ts @@ -171 +171 @@ export class ResourcesDropHandler { - return; -+ return (require('vs/../../../../packages/vscode') as typeof import ('vs/../../../../packages/vscode')).client.handleDrop(event, resolveTargetGroup, afterDrop, targetIndex); ++ return (require('vs/../../../../packages/vscode/src/workbench') as typeof import ('vs/../../../../packages/vscode/src/workbench')).workbench.handleDrop(event, resolveTargetGroup, afterDrop, targetIndex); +diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts +index 7213400c86..a54def1640 100644 +--- a/src/vs/workbench/browser/layout.ts ++++ b/src/vs/workbench/browser/layout.ts +@@ -29 +29 @@ import { getZoomFactor } from 'vs/base/browser/browser'; +-const TITLE_BAR_HEIGHT = isMacintosh ? 22 : 30; ++const TITLE_BAR_HEIGHT = /* isMacintosh ? 22 : */30; +diff --git a/src/vs/workbench/browser/parts/editor/editor.contribution.ts b/src/vs/workbench/browser/parts/editor/editor.contribution.ts +index b262c8aeef..4e23df1bc6 100644 +--- a/src/vs/workbench/browser/parts/editor/editor.contribution.ts ++++ b/src/vs/workbench/browser/parts/editor/editor.contribution.ts +@@ -48 +48 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/workbench/browser/parts/editor/editorDropTarget.ts b/src/vs/workbench/browser/parts/editor/editorDropTarget.ts +index 9eca348265..df1d84514f 100644 +--- a/src/vs/workbench/browser/parts/editor/editorDropTarget.ts ++++ b/src/vs/workbench/browser/parts/editor/editorDropTarget.ts +@@ -14 +14 @@ import { IEditorIdentifier, EditorInput, EditorOptions } from 'vs/workbench/comm +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/workbench/browser/parts/editor/resourceViewer.ts b/src/vs/workbench/browser/parts/editor/resourceViewer.ts +index a0cc90b573..781e0187a0 100644 +--- a/src/vs/workbench/browser/parts/editor/resourceViewer.ts ++++ b/src/vs/workbench/browser/parts/editor/resourceViewer.ts +@@ -23 +23 @@ import { memoize } from 'vs/base/common/decorators'; +-import * as platform from 'vs/base/common/platform'; ++import * as browser from 'vs/base/browser/browser'; +@@ -444 +444 @@ class InlineImageView { +- if (platform.isMacintosh ? altPressed : ctrlPressed) { ++ if (browser.isMacintosh ? altPressed : ctrlPressed) { +@@ -458 +458 @@ class InlineImageView { +- if (!(platform.isMacintosh ? altPressed : ctrlPressed)) { ++ if (!(browser.isMacintosh ? altPressed : ctrlPressed)) { +@@ -478 +478 @@ class InlineImageView { +- if (!(platform.isMacintosh ? altPressed : ctrlPressed)) { // zoom in ++ if (!(browser.isMacintosh ? altPressed : ctrlPressed)) { // zoom in +@@ -502 +502 @@ class InlineImageView { +- const isScrollWhellKeyPressed = platform.isMacintosh ? altPressed : ctrlPressed; ++ const isScrollWhellKeyPressed = browser.isMacintosh ? altPressed : ctrlPressed; +diff --git a/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts b/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts +index 5f957c221a..f29d27759e 100644 +--- a/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts ++++ b/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts +@@ -7 +7 @@ import 'vs/css!./media/tabstitlecontrol'; +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/workbench/browser/parts/quickinput/quickInputList.ts b/src/vs/workbench/browser/parts/quickinput/quickInputList.ts +index f24bb0bcc0..219a1dcae5 100644 +--- a/src/vs/workbench/browser/parts/quickinput/quickInputList.ts ++++ b/src/vs/workbench/browser/parts/quickinput/quickInputList.ts +@@ -24 +24 @@ import { range } from 'vs/base/common/arrays'; +-import * as platform from 'vs/base/common/platform'; ++import * as browser from 'vs/base/browser/browser'; +@@ -263 +263 @@ export class QuickInputList { +- if (platform.isMacintosh ? e.metaKey : e.ctrlKey) { ++ if (browser.isMacintosh ? e.metaKey : e.ctrlKey) { +diff --git a/src/vs/workbench/browser/parts/titlebar/media/titlebarpart.css b/src/vs/workbench/browser/parts/titlebar/media/titlebarpart.css +index 38794f793d..d4daa083bd 100644 +--- a/src/vs/workbench/browser/parts/titlebar/media/titlebarpart.css ++++ b/src/vs/workbench/browser/parts/titlebar/media/titlebarpart.css +@@ -44,0 +45 @@ ++.web > .monaco-workbench .part.titlebar, +diff --git a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts +index 121bf09bb8..f5d425300a 100644 +--- a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts ++++ b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts +@@ -16 +16,2 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; +-import { isMacintosh, isLinux } from 'vs/base/common/platform'; ++import { isNative } from 'vs/base/common/platform'; ++import { isMacintosh, isLinux } from 'vs/base/browser/browser'; +@@ -113 +114 @@ export class MenubarControl extends Disposable { +- if (isMacintosh) { ++ if (isNative && isMacintosh) { +@@ -119 +120 @@ export class MenubarControl extends Disposable { +- if (isMacintosh || this.currentTitlebarStyleSetting !== 'custom') { ++ if ((isNative && isMacintosh) || this.currentTitlebarStyleSetting !== 'custom') { +@@ -255 +256 @@ export class MenubarControl extends Disposable { +- if (!isMacintosh && this.currentTitlebarStyleSetting === 'custom') { ++ if (!(isNative && isMacintosh) && this.currentTitlebarStyleSetting === 'custom') { +@@ -271 +272 @@ export class MenubarControl extends Disposable { +- if (!isMacintosh && this.currentTitlebarStyleSetting === 'custom') { ++ if (!(isNative && isMacintosh) && this.currentTitlebarStyleSetting === 'custom') { +@@ -432 +433 @@ export class MenubarControl extends Disposable { +- if (!isMacintosh) { ++ if (!(isNative && isMacintosh)) { +@@ -648 +649 @@ export class MenubarControl extends Disposable { +- if (!isMacintosh && this.currentTitlebarStyleSetting === 'custom') { ++ if (!(isNative && isMacintosh) && this.currentTitlebarStyleSetting === 'custom') { +diff --git a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts +index 4b3eb7bdb8..9161baf086 100644 +--- a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts ++++ b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts +@@ -25 +25,2 @@ import { TITLE_BAR_ACTIVE_BACKGROUND, TITLE_BAR_ACTIVE_FOREGROUND, TITLE_BAR_INA +-import { isMacintosh, isWindows, isLinux } from 'vs/base/common/platform'; ++import { isNative } from 'vs/base/common/platform'; ++import { isMacintosh, isWindows, isLinux } from 'vs/base/browser/browser'; +@@ -320 +321 @@ export class TitlebarPart extends Part implements ITitleService, ISerializableVi +- if (!isMacintosh) { ++ if (!(isNative && isMacintosh)) { +@@ -336 +337 @@ export class TitlebarPart extends Part implements ITitleService, ISerializableVi +- if (!isMacintosh) { ++ if (!(isNative && isMacintosh)) { +@@ -543 +544 @@ export class TitlebarPart extends Part implements ITitleService, ISerializableVi +- if (!isMacintosh && ++ if (!(isNative && isMacintosh) && +@@ -559 +560 @@ export class TitlebarPart extends Part implements ITitleService, ISerializableVi +- if (isMacintosh || this.configurationService.getValue('window.menuBarVisibility') === 'hidden') { ++ if ((isNative && isMacintosh) || this.configurationService.getValue('window.menuBarVisibility') === 'hidden') { +diff --git a/src/vs/workbench/browser/workbench.contribution.ts b/src/vs/workbench/browser/workbench.contribution.ts +index 3798dbde4f..b0a5c23521 100644 +--- a/src/vs/workbench/browser/workbench.contribution.ts ++++ b/src/vs/workbench/browser/workbench.contribution.ts +@@ -9 +9 @@ import { IConfigurationRegistry, Extensions as ConfigurationExtensions, Configur +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/workbench/electron-browser/actions/helpActions.ts b/src/vs/workbench/electron-browser/actions/helpActions.ts +index 85d39d64d7..4b958dc79f 100644 +--- a/src/vs/workbench/electron-browser/actions/helpActions.ts ++++ b/src/vs/workbench/electron-browser/actions/helpActions.ts +@@ -9 +9,2 @@ import product from 'vs/platform/node/product'; +-import { isMacintosh, isLinux, language } from 'vs/base/common/platform'; ++import { language } from 'vs/base/common/platform'; ++import { isMacintosh, isLinux } from 'vs/base/browser/browser'; +diff --git a/src/vs/workbench/electron-browser/actions/windowActions.ts b/src/vs/workbench/electron-browser/actions/windowActions.ts +index 0cf3ec6611..b8b61194ba 100644 +--- a/src/vs/workbench/electron-browser/actions/windowActions.ts ++++ b/src/vs/workbench/electron-browser/actions/windowActions.ts +@@ -14 +14 @@ import { IWorkspaceConfigurationService } from 'vs/workbench/services/configurat +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts index 1e6333c731..0a7bdeeb9b 100644 --- a/src/vs/workbench/electron-browser/main.ts @@ -102,22 +507,155 @@ index 1e6333c731..0a7bdeeb9b 100644 + // } + // } + // }); +diff --git a/src/vs/workbench/electron-browser/shell.contribution.ts b/src/vs/workbench/electron-browser/shell.contribution.ts +index bc02c150a7..4ef622f669 100644 +--- a/src/vs/workbench/electron-browser/shell.contribution.ts ++++ b/src/vs/workbench/electron-browser/shell.contribution.ts +@@ -14 +14,2 @@ import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes'; +-import { isWindows, isLinux, isMacintosh } from 'vs/base/common/platform'; ++import { isNative, isWeb } from 'vs/base/common/platform'; ++import { isWindows, isLinux, isMacintosh } from 'vs/base/browser/browser'; +@@ -488 +489 @@ configurationRegistry.registerConfiguration({ +- isMacintosh ? ++ isNative && isMacintosh ? +@@ -495 +496 @@ configurationRegistry.registerConfiguration({ +- isMacintosh ? ++ isNative && isMacintosh ? +@@ -582 +583 @@ configurationRegistry.registerConfiguration({ +- 'included': isWindows || isLinux ++ 'included': isWeb || isWindows || isLinux +@@ -589 +590 @@ configurationRegistry.registerConfiguration({ +- 'included': isWindows || isLinux ++ 'included': isWeb || isWindows || isLinux +@@ -615 +616 @@ configurationRegistry.registerConfiguration({ +- 'included': isMacintosh && parseFloat(os.release()) >= 16 // Minimum: macOS Sierra (10.12.x = darwin 16.x) ++ 'included': isNative && isMacintosh && parseFloat(os.release()) >= 16 // Minimum: macOS Sierra (10.12.x = darwin 16.x) +@@ -621 +622 @@ configurationRegistry.registerConfiguration({ +- 'included': isMacintosh ++ 'included': isNative && isMacintosh +@@ -632 +632,0 @@ configurationRegistry.registerConfiguration({ +- +diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts +index fd95939506..5ed6fb52b2 100644 +--- a/src/vs/workbench/electron-browser/shell.ts ++++ b/src/vs/workbench/electron-browser/shell.ts +@@ -548 +548 @@ export class Shell extends Disposable { +- addClasses(this.container, 'monaco-shell', platform.isWindows ? 'windows' : platform.isLinux ? 'linux' : 'mac'); ++ addClasses(this.container, 'web monaco-shell', platform.isWindows ? 'windows' : platform.isLinux ? 'linux' : 'mac'); diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-browser/window.ts -index c0aff6bd4b..4f3b1e3984 100644 +index c0aff6bd4b..15af61a9ec 100644 --- a/src/vs/workbench/electron-browser/window.ts +++ b/src/vs/workbench/electron-browser/window.ts @@ -49 +49 @@ const TextInputActions: IAction[] = [ - new Action('editor.action.clipboardPasteAction', nls.localize('paste', "Paste"), undefined, true, () => Promise.resolve(document.execCommand('paste'))), -+ (require('vs/../../../../packages/vscode') as typeof import ('vs/../../../../packages/vscode')).client.pasteAction, ++ (require('vs/../../../../packages/vscode/src/workbench') as typeof import ('vs/../../../../packages/vscode/src/workbench')).workbench.pasteAction, @@ -263 +263 @@ export class ElectronWindow extends Themable { - (window).open = function (url: string, target: string, features: string, replace: boolean): any { + (window).openInvalid = function (url: string, target: string, features: string, replace: boolean): any { +@@ -304 +304 @@ export class ElectronWindow extends Themable { +- !isMacintosh || // macOS only ++ !browser.isMacintosh || // macOS only diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts -index d82db96296..c9bd4e0325 100644 +index d82db96296..ceabf4f791 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts -@@ -272,0 +273 @@ export class Workbench extends Disposable implements IPartService { -+ (require('vs/../../../../packages/vscode') as typeof import ('vs/../../../../packages/vscode')).client.serviceCollection = serviceCollection; +@@ -19 +19,2 @@ import { Registry } from 'vs/platform/registry/common/platform'; +-import { isWindows, isLinux, isMacintosh } from 'vs/base/common/platform'; ++import { isWeb, isNative } from 'vs/base/common/platform'; ++import { isWindows, isLinux, isMacintosh } from 'vs/base/browser/browser'; +@@ -272,0 +274 @@ export class Workbench extends Disposable implements IPartService { ++ (require('vs/../../../../packages/vscode/src/workbench') as typeof import ('vs/../../../../packages/vscode/src/workbench')).workbench.serviceCollection = serviceCollection; +@@ -380 +382 @@ export class Workbench extends Disposable implements IPartService { +- if (!isMacintosh && this.useCustomTitleBarStyle()) { ++ if (isWeb || (!isMacintosh && this.useCustomTitleBarStyle())) { +@@ -1098 +1100 @@ export class Workbench extends Disposable implements IPartService { +- if ((isWindows || isLinux) && this.useCustomTitleBarStyle()) { ++ if ((isWeb || isWindows || isLinux) && this.useCustomTitleBarStyle()) { +@@ -1265 +1267 @@ export class Workbench extends Disposable implements IPartService { +- } else if (isMacintosh) { ++ } else if (isNative && isMacintosh) { +diff --git a/src/vs/workbench/parts/codeEditor/electron-browser/accessibility.ts b/src/vs/workbench/parts/codeEditor/electron-browser/accessibility.ts +index 265a7bc474..8eef7e5d10 100644 +--- a/src/vs/workbench/parts/codeEditor/electron-browser/accessibility.ts ++++ b/src/vs/workbench/parts/codeEditor/electron-browser/accessibility.ts +@@ -15,0 +16 @@ import * as platform from 'vs/base/common/platform'; ++import * as browser from 'vs/base/browser/browser'; +@@ -196 +197 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { +- platform.isMacintosh ++ browser.isMacintosh +@@ -238 +239 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget { +- platform.isMacintosh ++ browser.isMacintosh +diff --git a/src/vs/workbench/parts/codeEditor/electron-browser/suggestEnabledInput.ts b/src/vs/workbench/parts/codeEditor/electron-browser/suggestEnabledInput.ts +index 8c692b4fcc..ce990c83d6 100644 +--- a/src/vs/workbench/parts/codeEditor/electron-browser/suggestEnabledInput.ts ++++ b/src/vs/workbench/parts/codeEditor/electron-browser/suggestEnabledInput.ts +@@ -14 +14 @@ import { mixin } from 'vs/base/common/objects'; +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/workbench/parts/codeEditor/electron-browser/toggleMultiCursorModifier.ts b/src/vs/workbench/parts/codeEditor/electron-browser/toggleMultiCursorModifier.ts +index 5e1b6da216..f8643d2e18 100644 +--- a/src/vs/workbench/parts/codeEditor/electron-browser/toggleMultiCursorModifier.ts ++++ b/src/vs/workbench/parts/codeEditor/electron-browser/toggleMultiCursorModifier.ts +@@ -8 +8 @@ import { Action } from 'vs/base/common/actions'; +-import * as platform from 'vs/base/common/platform'; ++import * as browser from 'vs/base/browser/browser'; +@@ -84 +84 @@ MenuRegistry.appendMenuItem(MenuId.MenubarSelectionMenu, { +- platform.isMacintosh ++ browser.isMacintosh +diff --git a/src/vs/workbench/parts/comments/electron-browser/commentNode.ts b/src/vs/workbench/parts/comments/electron-browser/commentNode.ts +index 5d1c0b3b43..dc4ed358c1 100644 +--- a/src/vs/workbench/parts/comments/electron-browser/commentNode.ts ++++ b/src/vs/workbench/parts/comments/electron-browser/commentNode.ts +@@ -26 +26 @@ import { KeyCode } from 'vs/base/common/keyCodes'; +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/workbench/parts/comments/electron-browser/commentThreadWidget.ts b/src/vs/workbench/parts/comments/electron-browser/commentThreadWidget.ts +index c5eea6a8d0..72f8329f2f 100644 +--- a/src/vs/workbench/parts/comments/electron-browser/commentThreadWidget.ts ++++ b/src/vs/workbench/parts/comments/electron-browser/commentThreadWidget.ts +@@ -15 +15 @@ import { IDisposable } from 'vs/base/common/lifecycle'; +-import * as platform from 'vs/base/common/platform'; ++import * as browser from 'vs/base/browser/browser'; +@@ -636 +636 @@ export class ReviewZoneWidget extends ZoneWidget { +- let keybinding = platform.isMacintosh ? 'Cmd+Enter' : 'Ctrl+Enter'; ++ let keybinding = browser.isMacintosh ? 'Cmd+Enter' : 'Ctrl+Enter'; +diff --git a/src/vs/workbench/parts/debug/browser/linkDetector.ts b/src/vs/workbench/parts/debug/browser/linkDetector.ts +index 49bb7903ac..624d03d56e 100644 +--- a/src/vs/workbench/parts/debug/browser/linkDetector.ts ++++ b/src/vs/workbench/parts/debug/browser/linkDetector.ts +@@ -9 +9 @@ import { URI as uri } from 'vs/base/common/uri'; +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts +index 2d640f1a84..cbc7353a20 100644 +--- a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts ++++ b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts +@@ -45 +45 @@ import { ViewsRegistry } from 'vs/workbench/common/views'; +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/workbench/parts/debug/electron-browser/debugEditorContribution.ts b/src/vs/workbench/parts/debug/electron-browser/debugEditorContribution.ts +index f6350174f3..5a884fc81b 100644 +--- a/src/vs/workbench/parts/debug/electron-browser/debugEditorContribution.ts ++++ b/src/vs/workbench/parts/debug/electron-browser/debugEditorContribution.ts +@@ -9,0 +10 @@ import * as env from 'vs/base/common/platform'; ++import * as browser from 'vs/base/browser/browser'; +@@ -180 +181 @@ export class DebugEditorContribution implements IDebugEditorContribution { +- if (e.event.rightButton || (env.isMacintosh && e.event.leftButton && e.event.ctrlKey)) { ++ if (e.event.rightButton || (browser.isMacintosh && e.event.leftButton && e.event.ctrlKey)) { +@@ -429 +430 @@ export class DebugEditorContribution implements IDebugEditorContribution { +- const stopKey = env.isMacintosh ? 'metaKey' : 'ctrlKey'; ++ const stopKey = browser.isMacintosh ? 'metaKey' : 'ctrlKey'; +@@ -447 +448 @@ export class DebugEditorContribution implements IDebugEditorContribution { +- const stopKey = env.isMacintosh ? KeyCode.Meta : KeyCode.Ctrl; ++ const stopKey = browser.isMacintosh ? KeyCode.Meta : KeyCode.Ctrl; +diff --git a/src/vs/workbench/parts/debug/electron-browser/repl.ts b/src/vs/workbench/parts/debug/electron-browser/repl.ts +index 21b493db79..b608d21912 100644 +--- a/src/vs/workbench/parts/debug/electron-browser/repl.ts ++++ b/src/vs/workbench/parts/debug/electron-browser/repl.ts +@@ -13 +13 @@ import * as aria from 'vs/base/browser/ui/aria/aria'; +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; diff --git a/src/vs/workbench/parts/debug/node/debugAdapter.ts b/src/vs/workbench/parts/debug/node/debugAdapter.ts index 81954344b9..2bdce9603e 100644 --- a/src/vs/workbench/parts/debug/node/debugAdapter.ts @@ -128,12 +666,29 @@ index 81954344b9..2bdce9603e 100644 @@ -320 +320 @@ export class ExecutableDebugAdapter extends StreamDebugAdapter { - if (!fs.existsSync(this.adapterExecutable.command)) { + if (!(await require("util").promisify(fs.exists)(this.adapterExecutable.command))) { +diff --git a/src/vs/workbench/parts/files/electron-browser/fileActions.contribution.ts b/src/vs/workbench/parts/files/electron-browser/fileActions.contribution.ts +index 1002950c75..8c187d36ff 100644 +--- a/src/vs/workbench/parts/files/electron-browser/fileActions.contribution.ts ++++ b/src/vs/workbench/parts/files/electron-browser/fileActions.contribution.ts +@@ -17 +17 @@ import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/co +-import { isWindows, isMacintosh } from 'vs/base/common/platform'; ++import { isWindows, isMacintosh } from 'vs/base/browser/browser'; +diff --git a/src/vs/workbench/parts/files/electron-browser/fileCommands.ts b/src/vs/workbench/parts/files/electron-browser/fileCommands.ts +index 0bd9b93fcc..1c8adeb5ca 100644 +--- a/src/vs/workbench/parts/files/electron-browser/fileCommands.ts ++++ b/src/vs/workbench/parts/files/electron-browser/fileCommands.ts +@@ -29 +29 @@ import { KeyMod, KeyCode, KeyChord } from 'vs/base/common/keyCodes'; +-import { isWindows, isMacintosh } from 'vs/base/common/platform'; ++import { isWindows, isMacintosh } from 'vs/base/browser/browser'; diff --git a/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts b/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts -index e66f74f034..759ffe0cef 100644 +index e66f74f034..e2c24d851a 100644 --- a/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts +++ b/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts +@@ -39 +39 @@ import { DesktopDragAndDropData, ExternalElementsDragAndDropData, ElementsDragAn +-import { isMacintosh, isLinux } from 'vs/base/common/platform'; ++import { isMacintosh, isLinux } from 'vs/base/browser/browser'; @@ -586,0 +587 @@ export class FileDragAndDrop implements ITreeDragAndDrop { -+ return (require('vs/../../../../packages/vscode') as typeof import('vs/../../../../packages/vscode')).client.handleExternalDrop(target, originalEvent); ++ return (require('vs/../../../../packages/vscode/src/workbench') as typeof import('vs/../../../../packages/vscode/src/workbench')).workbench.handleExternalDrop(target, originalEvent); diff --git a/src/vs/workbench/parts/logs/electron-browser/logs.contribution.ts b/src/vs/workbench/parts/logs/electron-browser/logs.contribution.ts index 4015c9cd5d..bebdb25f6c 100644 --- a/src/vs/workbench/parts/logs/electron-browser/logs.contribution.ts @@ -143,12 +698,89 @@ index 4015c9cd5d..bebdb25f6c 100644 + // This channel only seems to be used when loading the app and we skip all of that, so it is never actually created or written to. + // outputChannelRegistry.registerChannel({ id: Constants.mainLogChannelId, label: nls.localize('mainLog', "Main"), file: URI.file(join(environmentService.logsPath, `main.log`)), log: true }); diff --git a/src/vs/workbench/parts/output/common/outputLinkProvider.ts b/src/vs/workbench/parts/output/common/outputLinkProvider.ts -index 6d9451401a..510f5131ce 100644 +index 6d9451401a..15e4dcf366 100644 --- a/src/vs/workbench/parts/output/common/outputLinkProvider.ts +++ b/src/vs/workbench/parts/output/common/outputLinkProvider.ts -@@ -77,0 +78,2 @@ export class OutputLinkProvider { -+ +@@ -77,0 +78 @@ export class OutputLinkProvider { + return Promise.resolve([]); +diff --git a/src/vs/workbench/parts/quickopen/browser/quickopen.contribution.ts b/src/vs/workbench/parts/quickopen/browser/quickopen.contribution.ts +index e6ffdb918b..3960ca32e3 100644 +--- a/src/vs/workbench/parts/quickopen/browser/quickopen.contribution.ts ++++ b/src/vs/workbench/parts/quickopen/browser/quickopen.contribution.ts +@@ -6 +6 @@ +-import * as env from 'vs/base/common/platform'; ++import * as browser from 'vs/base/browser/browser'; +@@ -94 +94 @@ Registry.as(QuickOpenExtensions.Quickopen).registerQuickOpen +- description: env.isMacintosh ? nls.localize('gotoLineDescriptionMac', "Go to Line") : nls.localize('gotoLineDescriptionWin', "Go to Line") ++ description: browser.isMacintosh ? nls.localize('gotoLineDescriptionMac', "Go to Line") : nls.localize('gotoLineDescriptionWin', "Go to Line") +diff --git a/src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts b/src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts +index 21d823df72..25e16f7a6f 100644 +--- a/src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts ++++ b/src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts +@@ -18 +18,2 @@ import { isEqual } from 'vs/base/common/resources'; +-import { isLinux, isMacintosh } from 'vs/base/common/platform'; ++import { isNative, isLinux } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; +@@ -69 +70 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo +- if (isMacintosh && config.window && typeof config.window.nativeTabs === 'boolean' && config.window.nativeTabs !== this.nativeTabs) { ++ if (isNative && isMacintosh && config.window && typeof config.window.nativeTabs === 'boolean' && config.window.nativeTabs !== this.nativeTabs) { +@@ -75 +76 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo +- if (isMacintosh && config.window && typeof config.window.nativeFullScreen === 'boolean' && config.window.nativeFullScreen !== this.nativeFullScreen) { ++ if (isNative && isMacintosh && config.window && typeof config.window.nativeFullScreen === 'boolean' && config.window.nativeFullScreen !== this.nativeFullScreen) { +diff --git a/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts b/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts +index 920cc42b0a..be9f59e2a5 100644 +--- a/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts ++++ b/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts +@@ -51 +51 @@ import { IPanelDndController, Panel } from 'vs/base/browser/ui/splitview/panelvi +-import * as platform from 'vs/base/common/platform'; ++import * as browser from 'vs/base/browser/browser'; +@@ -817 +817 @@ export class RepositoryPanel extends ViewletPanel { +- const label = binding ? binding.getLabel() : (platform.isMacintosh ? 'Cmd+Enter' : 'Ctrl+Enter'); ++ const label = binding ? binding.getLabel() : (browser.isMacintosh ? 'Cmd+Enter' : 'Ctrl+Enter'); +diff --git a/src/vs/workbench/parts/search/electron-browser/search.contribution.ts b/src/vs/workbench/parts/search/electron-browser/search.contribution.ts +index a299f18b82..2013a81ab7 100644 +--- a/src/vs/workbench/parts/search/electron-browser/search.contribution.ts ++++ b/src/vs/workbench/parts/search/electron-browser/search.contribution.ts +@@ -657 +657 @@ configurationRegistry.registerConfiguration({ +- included: platform.isMacintosh ++ included: platform.isNative && platform.isMacintosh +diff --git a/src/vs/workbench/parts/tasks/common/problemMatcher.ts b/src/vs/workbench/parts/tasks/common/problemMatcher.ts +index a9889946c2..54bc6aa811 100644 +--- a/src/vs/workbench/parts/tasks/common/problemMatcher.ts ++++ b/src/vs/workbench/parts/tasks/common/problemMatcher.ts +@@ -222 +222 @@ export function createLineMatcher(matcher: ProblemMatcher): ILineMatcher { +-const endOfLine: string = Platform.OS === Platform.OperatingSystem.Windows ? '\r\n' : '\n'; ++const endOfLine: string = Platform.isWindows ? '\r\n' : '\n'; +diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts +index fb600958c8..0698638175 100644 +--- a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts ++++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts +@@ -12,0 +13 @@ import * as platform from 'vs/base/common/platform'; ++import * as browser from 'vs/base/browser/browser'; +@@ -219 +220 @@ configurationRegistry.registerConfiguration({ +- default: platform.isMacintosh ? 'selectWord' : platform.isWindows ? 'copyPaste' : 'default', ++ default: browser.isMacintosh ? 'selectWord' : browser.isWindows ? 'copyPaste' : 'default', +diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts +index 31a1d6fc8e..bcfe2b24ec 100644 +--- a/src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts ++++ b/src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts +@@ -7,0 +8 @@ import * as path from 'path'; ++import * as browser from 'vs/base/browser/browser'; +@@ -214 +215 @@ export class TerminalLinkHandler { +- return platform.isMacintosh ? event.metaKey : event.ctrlKey; ++ return browser.isMacintosh ? event.metaKey : event.ctrlKey; +@@ -222 +223 @@ export class TerminalLinkHandler { +- if (platform.isMacintosh) { ++ if (browser.isMacintosh) { +diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts +index 6395712ee9..f2d1c0769b 100644 +--- a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts ++++ b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts +@@ -8,0 +9 @@ import * as platform from 'vs/base/common/platform'; ++import * as browser from 'vs/base/browser/browser'; +@@ -232 +233 @@ export class TerminalPanel extends Panel { +- if (platform.isMacintosh) { ++ if (browser.isMacintosh) { diff --git a/src/vs/workbench/parts/webview/electron-browser/webview-pre.js b/src/vs/workbench/parts/webview/electron-browser/webview-pre.js index 29593dc6b6..dd3d25098d 100644 --- a/src/vs/workbench/parts/webview/electron-browser/webview-pre.js @@ -189,10 +821,20 @@ index 29593dc6b6..dd3d25098d 100644 + // supportFetchAPI: true, + // corsEnabled: true + // }); +diff --git a/src/vs/workbench/parts/webview/electron-browser/webview.contribution.ts b/src/vs/workbench/parts/webview/electron-browser/webview.contribution.ts +index 033bd98d00..ba776c5ff3 100644 +--- a/src/vs/workbench/parts/webview/electron-browser/webview.contribution.ts ++++ b/src/vs/workbench/parts/webview/electron-browser/webview.contribution.ts +@@ -24 +24 @@ import { InputFocusedContextKey } from 'vs/platform/workbench/common/contextkeys +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; diff --git a/src/vs/workbench/parts/webview/electron-browser/webviewElement.ts b/src/vs/workbench/parts/webview/electron-browser/webviewElement.ts -index 5d9110300f..ecdc40b0eb 100644 +index 5d9110300f..eb16014814 100644 --- a/src/vs/workbench/parts/webview/electron-browser/webviewElement.ts +++ b/src/vs/workbench/parts/webview/electron-browser/webviewElement.ts +@@ -21 +21 @@ import { endsWith } from 'vs/base/common/strings'; +-import { isMacintosh } from 'vs/base/common/platform'; ++import { isMacintosh } from 'vs/base/browser/browser'; @@ -261,0 +262,3 @@ export class WebviewElement extends Disposable { + Object.defineProperty(this._options, 'useSameOriginForRoot', { + value: true, @@ -237,11 +879,11 @@ index 147f05b246..fa89583203 100644 - this.modelService.updateModel(codeEditorModel, content.value); + this.modelService.updateModel(codeEditorModel, content); diff --git a/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts b/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts -index 29cbfd65c4..1091dc3c8a 100644 +index 29cbfd65c4..ee7e776bdb 100644 --- a/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts +++ b/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts @@ -33,0 +34 @@ function getSystemExtensionsRoot(): string { -+ return (require('vs/../../../../packages/vscode') as typeof import ('vs/../../../../packages/vscode')).client.builtInExtensionsDirectory; ++ return (require('vs/../../../../packages/vscode/src/fill/paths') as typeof import ('vs/../../../../packages/vscode/src/fill/paths')).getBuiltInExtensionsDirectory(); diff --git a/src/vs/workbench/services/extensions/node/extensionHostProcess.ts b/src/vs/workbench/services/extensions/node/extensionHostProcess.ts index 5f2935618c..af5498d7ac 100644 --- a/src/vs/workbench/services/extensions/node/extensionHostProcess.ts