Archived
1
0
This repository has been archived on 2024-09-09. You can view files and clone it, but cannot push or open issues or pull requests.
code-server/scripts/vscode.patch
Asher 4a80bcb42c
Make everything use active evals (#30)
* Add trace log level

* Use active eval to implement spdlog

* Split server/client active eval interfaces

Since all properties are *not* valid on both sides

* +200% fire resistance

* Implement exec using active evaluations

* Fully implement child process streams

* Watch impl, move child_process back to explicitly adding events

Automatically forwarding all events might be the right move, but wanna
think/discuss it a bit more because it didn't come out very cleanly.

* Would you like some args with that callback?

* Implement the rest of child_process using active evals

* Rampant memory leaks

Emit "kill" to active evaluations when client disconnects in order to
kill processes. Most likely won't be the final solution.

* Resolve some minor issues with output panel

* Implement node-pty with active evals

* Provide clearTimeout to vm sandbox

* Implement socket with active evals

* Extract some callback logic

Also remove some eval interfaces, need to re-think those.

* Implement net.Server and remainder of net.Socket using active evals

* Implement dispose for active evaluations

* Use trace for express requests

* Handle sending buffers through evaluation events

* Make event logging a bit more clear

* Fix some errors due to us not actually instantiating until connect/listen

* is this a commit message?

* We can just create the evaluator in the ctor

Not sure what I was thinking.

* memory leak for you, memory leak for everyone

* it's a ternary now

* Don't dispose automatically on close or error

The code may or may not be disposable at that point.

* Handle parsing buffers on the client side as well

* Remove unused protobuf

* Remove TypedValue

* Remove unused forkProvider and test

* Improve dispose pattern for active evals

* Socket calls close after error; no need to bind both

* Improve comment

* Comment is no longer wishy washy due to explicit boolean

* Simplify check for sendHandle and options

* Replace _require with __non_webpack_require__

Webpack will then replace this with `require` which we then provide to
the vm sandbox.

* Provide path.parse

* Prevent original-fs from loading

* Start with a pid of -1

vscode immediately checks the PID to see if the debug process launch
correctly, but of course we don't get the pid synchronously.

* Pass arguments to bootstrap-fork

* Fully implement streams

Was causing errors because internally the stream would set this.writing
to true and it would never become false, so subsequent messages would
never send.

* Fix serializing errors and streams emitting errors multiple times

* Was emitting close to data

* Fix missing path for spawned processes

* Move evaluation onDispose call

Now it's accurate and runs when the active evaluation has actually
disposed.

* Fix promisifying fs.exists

* Fix some active eval callback issues

* Patch existsSync in debug adapter
2019-02-19 10:17:03 -06:00

208 lines
14 KiB
Diff

diff --git a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts b/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts
index 457818a975..ad45ffe58a 100644
--- a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts
+++ b/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts
@@ -196,0 +197,2 @@ async function handshake(configuration: ISharedProcessConfiguration): Promise<vo
+
+startup({ machineId: "1" });
diff --git a/src/vs/editor/contrib/clipboard/clipboard.ts b/src/vs/editor/contrib/clipboard/clipboard.ts
index 5e43f1b39e..a008d3ac7e 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)
-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 {
+ const { client } = require('vs/../../../../packages/vscode') as typeof import ('vs/../../../../packages/vscode');
@@ -181 +183 @@ 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, client.clipboardContextKey),
@@ -191 +193,2 @@ class ExecCommandPasteAction extends ExecCommandAction {
- order: 3
+ order: 3,
+ when: client.clipboardContextKey,
@@ -194,0 +198,14 @@ class ExecCommandPasteAction extends ExecCommandAction {
+
+ public async run(accessor, editor: ICodeEditor): Promise<void> {
+ 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,
+ });
+ } catch (ex) {
+ super.run(accessor, editor);
+ }
+ } else {
+ super.run(accessor, editor);
+ }
+ }
diff --git a/src/vs/loader.js b/src/vs/loader.js
index 2bf7fe37d7..81cc668f12 100644
--- a/src/vs/loader.js
+++ b/src/vs/loader.js
@@ -670,4 +670,4 @@ var AMDLoader;
- this._fs = nodeRequire('fs');
- this._vm = nodeRequire('vm');
- this._path = nodeRequire('path');
- this._crypto = nodeRequire('crypto');
+ this._fs = require('fs');
+ this._vm = require('vm');
+ this._path = require('path');
+ this._crypto = require('crypto');
@@ -733,0 +734,7 @@ var AMDLoader;
+ const context = require.context("../", true, /.*/);
+ if (scriptSrc.indexOf("file:///") !== -1) {
+ const vsSrc = scriptSrc.split("file:///")[1].split(".js")[0];
+ if (vsSrc && vsSrc.startsWith("vs/")) {
+ scriptSrc = `node|./${vsSrc}`;
+ }
+ }
@@ -738 +745 @@ var AMDLoader;
- moduleExports_1 = nodeRequire(pieces[1]);
+ moduleExports_1 = context(pieces[1]);
diff --git a/src/vs/workbench/api/electron-browser/mainThreadHeapService.ts b/src/vs/workbench/api/electron-browser/mainThreadHeapService.ts
index e3efb95b75..163bc4c994 100644
--- a/src/vs/workbench/api/electron-browser/mainThreadHeapService.ts
+++ b/src/vs/workbench/api/electron-browser/mainThreadHeapService.ts
@@ -57,0 +58,3 @@ export class HeapService implements IHeapService {
+ // Cannot control GC in the browser.
+ return Promise.resolve(obj);
+
diff --git a/src/vs/workbench/api/node/extHostExtensionService.ts b/src/vs/workbench/api/node/extHostExtensionService.ts
index 7841dcdaa2..f5665f0db3 100644
--- a/src/vs/workbench/api/node/extHostExtensionService.ts
+++ b/src/vs/workbench/api/node/extHostExtensionService.ts
@@ -654 +654 @@ function loadCommonJSModule<T>(logService: ILogService, modulePath: string, acti
- r = require.__$__nodeRequire<T>(modulePath);
+ r = (global as any).nativeNodeRequire(modulePath);
diff --git a/src/vs/workbench/browser/dnd.ts b/src/vs/workbench/browser/dnd.ts
index 38bf337a61..a6ee664a20 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);
diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts
index a43d63aa51..438d0a8245 100644
--- a/src/vs/workbench/electron-browser/main.ts
+++ b/src/vs/workbench/electron-browser/main.ts
@@ -150,7 +150,7 @@ function openWorkbench(configuration: IWindowConfiguration): Promise<void> {
- (<any>self).require.config({
- onError: err => {
- if (err.errorCode === 'load') {
- shell.onUnexpectedError(new Error(nls.localize('loaderErrorNative', "Failed to load a required file. Please restart the application to try again. Details: {0}", JSON.stringify(err))));
- }
- }
- });
+ // (<any>self).require.config({
+ // onError: err => {
+ // if (err.errorCode === 'load') {
+ // shell.onUnexpectedError(new Error(nls.localize('loaderErrorNative', "Failed to load a required file. Please restart the application to try again. Details: {0}", JSON.stringify(err))));
+ // }
+ // }
+ // });
diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-browser/window.ts
index ea348f3a04..ada0003fea 100644
--- a/src/vs/workbench/electron-browser/window.ts
+++ b/src/vs/workbench/electron-browser/window.ts
@@ -48 +48 @@ const TextInputActions: IAction[] = [
- new Action('editor.action.clipboardPasteAction', nls.localize('paste', "Paste"), null, true, () => document.execCommand('paste') && Promise.resolve(true)),
+ (require('vs/../../../../packages/vscode') as typeof import ('vs/../../../../packages/vscode')).client.pasteAction,
diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts
index 35bc4a82b3..45e96001b6 100644
--- a/src/vs/workbench/electron-browser/workbench.ts
+++ b/src/vs/workbench/electron-browser/workbench.ts
@@ -250,0 +251 @@ export class Workbench extends Disposable implements IPartService {
+ (require('vs/../../../../packages/vscode') as typeof import ('vs/../../../../packages/vscode')).client.serviceCollection = serviceCollection;
diff --git a/src/vs/workbench/node/extensionHostProcess.ts b/src/vs/workbench/node/extensionHostProcess.ts
index 8d182d18d9..69d51e1aea 100644
--- a/src/vs/workbench/node/extensionHostProcess.ts
+++ b/src/vs/workbench/node/extensionHostProcess.ts
@@ -132 +132 @@ function connectToRenderer(protocol: IMessagePassingProtocol): Promise<IRenderer
- process.kill(initData.parentPid, 0); // throws an exception if the main process doesn't exist anymore.
+ // process.kill(initData.parentPid, 0); // throws an exception if the main process doesn't exist anymore.
diff --git a/src/vs/workbench/parts/debug/node/debugAdapter.ts b/src/vs/workbench/parts/debug/node/debugAdapter.ts
index 2d798bf2df..9ccadacb3a 100644
--- a/src/vs/workbench/parts/debug/node/debugAdapter.ts
+++ b/src/vs/workbench/parts/debug/node/debugAdapter.ts
@@ -315 +315 @@ export class ExecutableDebugAdapter extends StreamDebugAdapter {
- return new Promise<void>((resolve, reject) => {
+ return new Promise<void>(async (resolve, reject) => {
@@ -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/views/explorerViewer.ts b/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
index e600fb2f78..1e0dc9a220 100644
--- a/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
+++ b/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
@@ -934,0 +935 @@ export class FileDragAndDrop extends SimpleFileResourceDragAndDrop {
+ return (require('vs/../../../../packages/vscode') as typeof import ('vs/../../../../packages/vscode')).client.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
+++ b/src/vs/workbench/parts/logs/electron-browser/logs.contribution.ts
@@ -31 +31,2 @@ class LogOutputChannels extends Disposable implements IWorkbenchContribution {
- outputChannelRegistry.registerChannel({ id: Constants.mainLogChannelId, label: nls.localize('mainLog', "Main"), file: URI.file(join(environmentService.logsPath, `main.log`)), log: true });
+ // 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 63437034c9..acd82c8375 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 {
+ // TODO@coder: get this working.
+ return Promise.resolve([]);
diff --git a/src/vs/workbench/parts/welcome/walkThrough/node/walkThroughContentProvider.ts b/src/vs/workbench/parts/welcome/walkThrough/node/walkThroughContentProvider.ts
index 7b4e8721ac..96d612f940 100644
--- a/src/vs/workbench/parts/welcome/walkThrough/node/walkThroughContentProvider.ts
+++ b/src/vs/workbench/parts/welcome/walkThrough/node/walkThroughContentProvider.ts
@@ -31,6 +31,6 @@ export class WalkThroughContentProvider implements ITextModelContentProvider, IW
- require([query.moduleId], content => {
- try {
- resolve(content.default());
- } catch (err) {
- reject(err);
- }
+ // This works because the only walkthrough that is a module is the welcome page.
+ // We have to explicitly import it or Webpack won't pick it up.
+ import("vs/workbench/parts/welcome/page/electron-browser/vs_code_welcome_page").then((content) => {
+ resolve(content.default());
+ }).catch((err) => {
+ reject(err);
@@ -38 +38,3 @@ export class WalkThroughContentProvider implements ITextModelContentProvider, IW
- }) : this.textFileService.resolveTextContent(URI.file(resource.fsPath)).then(content => content.value));
+ }) : (resource.scheme !== "file"
+ ? fetch(resource.path).then((res) => res.text())
+ : this.textFileService.resolveTextContent(URI.file(resource.fsPath)).then(content => content.value)));
@@ -64 +66 @@ export class WalkThroughSnippetContentProvider implements ITextModelContentProvi
- return this.textFileService.resolveTextContent(URI.file(resource.fsPath)).then(content => {
+ return fetch(resource.path).then((res) => res.text()).then((content) => {
@@ -81,5 +83,5 @@ export class WalkThroughSnippetContentProvider implements ITextModelContentProvi
- const textBuffer = content.value.create(DefaultEndOfLine.LF);
- const lineCount = textBuffer.getLineCount();
- const range = new Range(1, 1, lineCount, textBuffer.getLineLength(lineCount) + 1);
- const markdown = textBuffer.getValueInRange(range, EndOfLinePreference.TextDefined);
- marked(markdown, { renderer });
+ // const textBuffer = content.value.create(DefaultEndOfLine.LF);
+ // const lineCount = textBuffer.getLineCount();
+ // const range = new Range(1, 1, lineCount, textBuffer.getLineLength(lineCount) + 1);
+ // const markdown = textBuffer.getValueInRange(range, EndOfLinePreference.TextDefined);
+ marked(content, { renderer });
@@ -91 +93 @@ export class WalkThroughSnippetContentProvider implements ITextModelContentProvi
- 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 4cb7a231f3..78c87d13f6 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;
diff --git a/src/vs/workbench/services/themes/electron-browser/fileIconThemeData.ts b/src/vs/workbench/services/themes/electron-browser/fileIconThemeData.ts
index 5b4136989f..25ccc0fe9e 100644
--- a/src/vs/workbench/services/themes/electron-browser/fileIconThemeData.ts
+++ b/src/vs/workbench/services/themes/electron-browser/fileIconThemeData.ts
@@ -181 +181 @@ function _processIconThemeDocument(id: string, iconThemeDocumentLocation: URI, i
- return resources.joinPath(iconThemeDocumentLocationDirname, path);
+ return "/resource" + resources.joinPath(iconThemeDocumentLocationDirname, path).path;