diff --git a/packages/server/src/cli.ts b/packages/server/src/cli.ts index 118ddb5a44b8..7183d45b27e3 100644 --- a/packages/server/src/cli.ts +++ b/packages/server/src/cli.ts @@ -26,10 +26,11 @@ commander.version(process.env.VERSION || "development") .option("-h, --host ", "Customize the hostname.", "0.0.0.0") .option("-o, --open", "Open in the browser on startup.", false) .option("-p, --port ", "Port to bind on.", parseInt(process.env.PORT!, 10) || 8443) - .option("-N, --no-auth", "Start without requiring authentication.", undefined) + .option("-N, --no-auth", "Start without requiring authentication.", false) .option("-H, --allow-http", "Allow http connections.", false) .option("-P, --password ", "DEPRECATED: Use the PASSWORD environment variable instead. Specify a password for authentication.") .option("--disable-telemetry", "Disables ALL telemetry.", false) + .option("--socket ", "Listen on a UNIX socket. Host and port will be ignored when set.") .option("--install-extension ", "Install an extension by its ID.") .option("--bootstrap-fork ", "Used for development. Never set.") .option("--extra-args ", "Used for development. Never set.") @@ -63,6 +64,7 @@ const bold = (text: string | number): string | number => { readonly open?: boolean; readonly cert?: string; readonly certKey?: string; + readonly socket?: string; readonly installExtension?: string; @@ -267,7 +269,11 @@ const bold = (text: string | number): string | number => { }); logger.info("Starting webserver...", field("host", options.host), field("port", options.port)); - app.server.listen(options.port, options.host); + if (options.socket) { + app.server.listen(options.socket); + } else { + app.server.listen(options.port, options.host); + } let clientId = 1; app.wss.on("connection", (ws, req) => { const id = clientId++; @@ -284,7 +290,11 @@ const bold = (text: string | number): string | number => { }); app.wss.on("error", (err: NodeJS.ErrnoException) => { if (err.code === "EADDRINUSE") { - logger.error(`Port ${bold(options.port)} is in use. Please free up port ${options.port} or specify a different port with the -p flag`); + if (options.socket) { + logger.error(`Socket ${bold(options.socket)} is in use. Please specify a different socket.`); + } else { + logger.error(`Port ${bold(options.port)} is in use. Please free up port ${options.port} or specify a different port with the -p flag`); + } process.exit(1); } }); @@ -300,8 +310,12 @@ const bold = (text: string | number): string | number => { } else { logger.warn("Launched without authentication."); } + if (options.disableTelemetry) { + logger.info("Telemetry is disabled"); + } - const url = `http://localhost:${options.port}/`; + const protocol = options.allowHttp ? "http" : "https"; + const url = `${protocol}://localhost:${options.port}/`; logger.info(" "); logger.info("Started (click the link below to open):"); logger.info(url); diff --git a/packages/server/src/server.ts b/packages/server/src/server.ts index 1b112bfe191e..b7d9a12cdbee 100644 --- a/packages/server/src/server.ts +++ b/packages/server/src/server.ts @@ -133,7 +133,7 @@ export const createApp = async (options: CreateAppOptions): Promise<{ }); }); - const server = httpolyglot.createServer(options.bypassAuth ? {} : options.httpsOptions || certs, app) as http.Server; + const server = httpolyglot.createServer(options.allowHttp ? {} : options.httpsOptions || certs, app) as http.Server; const wss = new ws.Server({ server }); wss.shouldHandle = (req): boolean => { diff --git a/packages/vscode/src/fill/vscodeTextmate.ts b/packages/vscode/src/fill/vscodeTextmate.ts index 06a097fa64f6..47b3cae6f0a7 100644 --- a/packages/vscode/src/fill/vscodeTextmate.ts +++ b/packages/vscode/src/fill/vscodeTextmate.ts @@ -2,6 +2,17 @@ import * as vscodeTextmate from "../../../../lib/vscode/node_modules/vscode-text const target = vscodeTextmate as typeof vscodeTextmate; +const ctx = (require as any).context("../../../../lib/extensions", true, /.*\.tmLanguage.json$/); +// Maps grammar scope to loaded grammar +const scopeToGrammar = {} as any; + +ctx.keys().forEach((key: string) => { + const value = ctx(key); + if (value.scopeName) { + scopeToGrammar[value.scopeName] = value; + } +}); + target.Registry = class Registry extends vscodeTextmate.Registry { public constructor(opts: vscodeTextmate.RegistryOptions) { super({ @@ -21,6 +32,13 @@ target.Registry = class Registry extends vscodeTextmate.Registry { }).catch(reason => rej(reason)); }); }, + loadGrammar: async (scopeName: string) => { + if (scopeToGrammar[scopeName]) { + return scopeToGrammar[scopeName]; + } + + return opts.loadGrammar(scopeName); + }, }); } }; diff --git a/scripts/vscode.patch b/scripts/vscode.patch index 1a5d76c1612b..8e89e69e2af4 100644 --- a/scripts/vscode.patch +++ b/scripts/vscode.patch @@ -175,7 +175,7 @@ index 1f8b17a..2a875f9 100644 + await cli.main(args); + return; // Always just do this for now. diff --git a/src/vs/editor/browser/config/configuration.ts b/src/vs/editor/browser/config/configuration.ts -index f97a692..0206957 100644 +index f97a692..8059a67 100644 --- a/src/vs/editor/browser/config/configuration.ts +++ b/src/vs/editor/browser/config/configuration.ts @@ -10 +9,0 @@ import { Disposable } from 'vs/base/common/lifecycle'; @@ -187,9 +187,6 @@ index f97a692..0206957 100644 @@ -367 +366 @@ export class Configuration extends CommonEditorConfiguration { - if (platform.isMacintosh) { + if (browser.isMacintosh) { -@@ -378 +377 @@ export class Configuration extends CommonEditorConfiguration { -- emptySelectionClipboard: browser.isWebKit || browser.isFirefox, -+ emptySelectionClipboard: false, // browser.isWebKit || browser.isFirefox, diff --git a/src/vs/editor/browser/controller/mouseHandler.ts b/src/vs/editor/browser/controller/mouseHandler.ts index b3b4472..f888d63 100644 --- a/src/vs/editor/browser/controller/mouseHandler.ts @@ -250,32 +247,55 @@ index c69ea3f..b8d87f7 100644 -const GOLDEN_LINE_HEIGHT_RATIO = platform.isMacintosh ? 1.5 : 1.35; +const GOLDEN_LINE_HEIGHT_RATIO = browser.isMacintosh ? 1.5 : 1.35; diff --git a/src/vs/editor/contrib/clipboard/clipboard.ts b/src/vs/editor/contrib/clipboard/clipboard.ts -index 990be3a..8a326c6 100644 +index 990be3a..18ae0d5 100644 --- a/src/vs/editor/contrib/clipboard/clipboard.ts +++ b/src/vs/editor/contrib/clipboard/clipboard.ts -@@ -29 +29,2 @@ const supportsCopyWithSyntaxHighlighting = (supportsCopy && !browser.isEdgeOrIE) +@@ -18,0 +19 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis ++import { clipboard } from 'electron'; +@@ -29 +30,2 @@ const supportsCopyWithSyntaxHighlighting = (supportsCopy && !browser.isEdgeOrIE) -const supportsPaste = (platform.isNative || (!browser.isChrome && document.queryCommandSupported('paste'))); +// const supportsPaste = (platform.isNative || (!browser.isChrome && document.queryCommandSupported('paste'))); +const supportsPaste = true; -@@ -176,0 +178 @@ class ExecCommandPasteAction extends ExecCommandAction { +@@ -71 +73 @@ class ExecCommandCutAction extends ExecCommandAction { +- kbOpts = null; ++ // kbOpts = null; +@@ -119 +121 @@ class ExecCommandCopyAction extends ExecCommandAction { +- kbOpts = null; ++ // kbOpts = null; +@@ -174 +176 @@ class ExecCommandPasteAction extends ExecCommandAction { +- kbOpts = null; ++ // kbOpts = null; +@@ -176,0 +179 @@ class ExecCommandPasteAction extends ExecCommandAction { + const { workbench } = require('vs/../../../../packages/vscode/src/workbench') as typeof import ('vs/../../../../packages/vscode/src/workbench'); -@@ -181 +183 @@ class ExecCommandPasteAction extends ExecCommandAction { +@@ -181 +184 @@ class ExecCommandPasteAction extends ExecCommandAction { - precondition: EditorContextKeys.writable, + precondition: (require('vs/platform/contextkey/common/contextkey') as typeof import('vs/platform/contextkey/common/contextkey')).ContextKeyExpr.and(EditorContextKeys.writable, workbench.clipboardContextKey), -@@ -191 +193,2 @@ class ExecCommandPasteAction extends ExecCommandAction { +@@ -191 +194,2 @@ class ExecCommandPasteAction extends ExecCommandAction { - order: 3 + order: 3, + when: workbench.clipboardContextKey, -@@ -194,0 +198,14 @@ class ExecCommandPasteAction extends ExecCommandAction { +@@ -194,0 +199,26 @@ class ExecCommandPasteAction extends ExecCommandAction { + + public async run(accessor, editor: ICodeEditor): 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/src/workbench') as typeof import ('vs/../../../../packages/vscode/src/workbench')).workbench.clipboardText, ++ editor.focus(); ++ const textInput = document.activeElement! as HTMLTextAreaElement; ++ const dataTransfer = new DataTransfer(); ++ const value = await clipboard.readText(); ++ dataTransfer.setData("text/plain", value); ++ const pasteEvent = new ClipboardEvent("paste", { ++ clipboardData: dataTransfer, + }); ++ textInput.dispatchEvent(pasteEvent); + } catch (ex) { -+ super.run(accessor, editor); ++ try { ++ editor.trigger('', (require('vs/editor/common/editorCommon') as typeof import ('vs/editor/common/editorCommon')).Handler.Paste, { ++ text: await (require('vs/../../../../packages/vscode/src/workbench') as typeof import ('vs/../../../../packages/vscode/src/workbench')).workbench.clipboardText, ++ }); ++ } catch (ex) { ++ super.run(accessor, editor); ++ } + } + } else { + super.run(accessor, editor); @@ -807,7 +827,7 @@ index 780147c..2e8c9af 100644 - if (platform.isMacintosh) { + if (browser.isMacintosh) { diff --git a/src/vs/workbench/contrib/webview/electron-browser/webview-pre.js b/src/vs/workbench/contrib/webview/electron-browser/webview-pre.js -index 74fc798..03728d0 100644 +index 74fc798..0b6b5eb 100644 --- a/src/vs/workbench/contrib/webview/electron-browser/webview-pre.js +++ b/src/vs/workbench/contrib/webview/electron-browser/webview-pre.js @@ -10 +10,19 @@ @@ -846,6 +866,11 @@ index 74fc798..03728d0 100644 + // supportFetchAPI: true, + // corsEnabled: true + // }); +@@ -328 +346,3 @@ +- newFrame.contentWindow.focus(); ++ if (document.hasFocus()) { ++ newFrame.contentWindow.focus(); ++ } diff --git a/src/vs/workbench/contrib/webview/electron-browser/webview.contribution.ts b/src/vs/workbench/contrib/webview/electron-browser/webview.contribution.ts index 484ff86..f3f57cb 100644 --- a/src/vs/workbench/contrib/webview/electron-browser/webview.contribution.ts