vscode.patch 15.3 KB
Newer Older
A
Asher 已提交
1 2 3 4 5 6 7 8 9 10
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
@@ -194,3 +194,5 @@ async function handshake(configuration: ISharedProcessConfiguration): Promise<vo
 	main(server, data, configuration);
 	ipcRenderer.send('handshake:im ready');
 }
+
+startup({ machineId: "1" });
11
diff --git a/src/vs/editor/contrib/clipboard/clipboard.ts b/src/vs/editor/contrib/clipboard/clipboard.ts
A
Asher 已提交
12
index 5e43f1b39e..a008d3ac7e 100644
13 14
--- a/src/vs/editor/contrib/clipboard/clipboard.ts
+++ b/src/vs/editor/contrib/clipboard/clipboard.ts
A
Asher 已提交
15
@@ -26,7 +26,8 @@ const supportsCopyWithSyntaxHighlighting = (supportsCopy && !browser.isEdgeOrIE)
16 17 18 19 20 21 22 23 24
 // Chrome incorrectly returns true for document.queryCommandSupported('paste')
 // when the paste feature is available but the calling script has insufficient
 // privileges to actually perform the action
-const supportsPaste = (platform.isNative || (!browser.isChrome && document.queryCommandSupported('paste')));
+// const supportsPaste = (platform.isNative || (!browser.isChrome && document.queryCommandSupported('paste')));
+const supportsPaste = true;
 
 type ExecCommand = 'cut' | 'copy' | 'paste';
 
A
Asher 已提交
25 26 27 28 29 30
@@ -174,11 +175,12 @@ class ExecCommandPasteAction extends ExecCommandAction {
 			kbOpts = null;
 		}
 
+		const { client } = require('vs/../../../../packages/vscode') as typeof import ('vs/../../../../packages/vscode');
 		super('paste', {
31 32 33 34
 			id: 'editor.action.clipboardPasteAction',
 			label: nls.localize('actions.clipboard.pasteLabel', "Paste"),
 			alias: 'Paste',
-			precondition: EditorContextKeys.writable,
A
Asher 已提交
35
+			precondition: (require('vs/platform/contextkey/common/contextkey') as typeof import('vs/platform/contextkey/common/contextkey')).ContextKeyExpr.and(EditorContextKeys.writable, client.clipboardContextKey),
36 37 38
 			kbOpts: kbOpts,
 			menuOpts: {
 				group: CLIPBOARD_CONTEXT_MENU_GROUP,
A
Asher 已提交
39
@@ -188,10 +190,25 @@ class ExecCommandPasteAction extends ExecCommandAction {
40 41 42 43 44 45 46 47 48 49 50
 				menuId: MenuId.MenubarEditMenu,
 				group: '2_ccp',
 				title: nls.localize({ key: 'miPaste', comment: ['&& denotes a mnemonic'] }, "&&Paste"),
-				order: 3
+				order: 3,
+				when: client.clipboardContextKey,
 			}
 		});
 	}
+
+	public async run(accessor, editor: ICodeEditor): Promise<void> {
A
Asher 已提交
51
+		if (editor instanceof (require('vs/editor/browser/widget/codeEditorWidget') as typeof import('vs/editor/browser/widget/codeEditorWidget')).CodeEditorWidget) {
52
+			try {
A
Asher 已提交
53 54
+				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,
55 56 57 58 59 60 61 62 63 64 65
+				});
+			} catch (ex) {
+				super.run(accessor, editor);
+			}
+		} else {
+			super.run(accessor, editor);
+		}
+	}
 }
 
 class ExecCommandCopyWithSyntaxHighlightingAction extends ExecCommandAction {
A
Asher 已提交
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
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
@@ -667,10 +667,10 @@ var AMDLoader;
             }
             this._didInitialize = true;
             // capture node modules
-            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');
         };
         // patch require-function of nodejs such that we can manually create a script
         // from cached data. this is done by overriding the `Module._compile` function
@@ -731,11 +731,18 @@ var AMDLoader;
             this._init(nodeRequire);
             this._initNodeRequire(nodeRequire, moduleManager);
             var recorder = moduleManager.getRecorder();
+            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}`;
+                }
+            }
             if (/^node\|/.test(scriptSrc)) {
                 var pieces = scriptSrc.split('|');
                 var moduleExports_1 = null;
                 try {
-                    moduleExports_1 = nodeRequire(pieces[1]);
+                    moduleExports_1 = context(pieces[1]);
                 }
                 catch (err) {
                     errorback(err);
A
Asher 已提交
105
diff --git a/src/vs/workbench/api/electron-browser/mainThreadHeapService.ts b/src/vs/workbench/api/electron-browser/mainThreadHeapService.ts
A
Asher 已提交
106
index e3efb95b75..163bc4c994 100644
A
Asher 已提交
107 108 109 110 111 112
--- a/src/vs/workbench/api/electron-browser/mainThreadHeapService.ts
+++ b/src/vs/workbench/api/electron-browser/mainThreadHeapService.ts
@@ -55,6 +55,9 @@ export class HeapService implements IHeapService {
 
 	private _doTrackRecursive(obj: any): Promise<any> {
 
A
Asher 已提交
113
+		// Cannot control GC in the browser.
A
Asher 已提交
114 115 116 117 118
+		return Promise.resolve(obj);
+
 		if (isNullOrUndefined(obj)) {
 			return Promise.resolve(obj);
 		}
A
Asher 已提交
119
diff --git a/src/vs/workbench/browser/dnd.ts b/src/vs/workbench/browser/dnd.ts
A
Asher 已提交
120
index 38bf337a61..a6ee664a20 100644
A
Asher 已提交
121 122
--- a/src/vs/workbench/browser/dnd.ts
+++ b/src/vs/workbench/browser/dnd.ts
A
Asher 已提交
123
@@ -168,7 +168,7 @@ export class ResourcesDropHandler {
A
Asher 已提交
124 125 126 127
 	handleDrop(event: DragEvent, resolveTargetGroup: () => IEditorGroup, afterDrop: (targetGroup: IEditorGroup) => void, targetIndex?: number): void {
 		const untitledOrFileResources = extractResources(event).filter(r => this.fileService.canHandleResource(r.resource) || r.resource.scheme === Schemas.untitled);
 		if (!untitledOrFileResources.length) {
-			return;
A
Asher 已提交
128
+			return (require('vs/../../../../packages/vscode') as typeof import ('vs/../../../../packages/vscode')).client.handleDrop(event, resolveTargetGroup, afterDrop, targetIndex);
A
Asher 已提交
129 130 131
 		}
 
 		// Make the window active to handle the drop properly within
A
Asher 已提交
132
diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts
A
Asher 已提交
133
index a43d63aa51..438d0a8245 100644
A
Asher 已提交
134 135
--- a/src/vs/workbench/electron-browser/main.ts
+++ b/src/vs/workbench/electron-browser/main.ts
A
Asher 已提交
136
@@ -147,13 +147,13 @@ function openWorkbench(configuration: IWindowConfiguration): Promise<void> {
A
Asher 已提交
137
 				shell.open();
A
Asher 已提交
138
 
A
Asher 已提交
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
 				// Inform user about loading issues from the loader
-				(<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))));
+				// 		}
+				// 	}
+				// });
 			});
 		});
 	});
157
diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-browser/window.ts
A
Asher 已提交
158
index ea348f3a04..ada0003fea 100644
159 160
--- a/src/vs/workbench/electron-browser/window.ts
+++ b/src/vs/workbench/electron-browser/window.ts
A
Asher 已提交
161
@@ -45,7 +45,7 @@ const TextInputActions: IAction[] = [
162 163 164 165
 	new Separator(),
 	new Action('editor.action.clipboardCutAction', nls.localize('cut', "Cut"), null, true, () => document.execCommand('cut') && Promise.resolve(true)),
 	new Action('editor.action.clipboardCopyAction', nls.localize('copy', "Copy"), null, true, () => document.execCommand('copy') && Promise.resolve(true)),
-	new Action('editor.action.clipboardPasteAction', nls.localize('paste', "Paste"), null, true, () => document.execCommand('paste') && Promise.resolve(true)),
A
Asher 已提交
166
+	(require('vs/../../../../packages/vscode') as typeof import ('vs/../../../../packages/vscode')).client.pasteAction,
167 168 169
 	new Separator(),
 	new Action('editor.action.selectAll', nls.localize('selectAll', "Select All"), null, true, () => document.execCommand('selectAll') && Promise.resolve(true))
 ];
A
Asher 已提交
170
diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts
A
Asher 已提交
171
index 35bc4a82b3..45e96001b6 100644
A
Asher 已提交
172 173
--- a/src/vs/workbench/electron-browser/workbench.ts
+++ b/src/vs/workbench/electron-browser/workbench.ts
A
Asher 已提交
174
@@ -248,6 +248,7 @@ export class Workbench extends Disposable implements IPartService {
A
Asher 已提交
175 176 177
 		super();
 
 		this.workbenchParams = { configuration, serviceCollection };
A
Asher 已提交
178
+		(require('vs/../../../../packages/vscode') as typeof import ('vs/../../../../packages/vscode')).client.serviceCollection = serviceCollection;
A
Asher 已提交
179 180 181
 
 		this.hasInitialFilesToOpen =
 			(configuration.filesToCreate && configuration.filesToCreate.length > 0) ||
A
Asher 已提交
182 183 184 185 186 187 188 189 190 191 192 193 194
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
@@ -129,7 +129,7 @@ function connectToRenderer(protocol: IMessagePassingProtocol): Promise<IRenderer
 			// Kill oneself if one's parent dies. Much drama.
 			setInterval(function () {
 				try {
-					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.
 				} catch (e) {
 					onTerminate();
 				}
A
Asher 已提交
195
diff --git a/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts b/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
A
Asher 已提交
196
index e600fb2f78..1e0dc9a220 100644
A
Asher 已提交
197 198
--- a/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
+++ b/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
A
Asher 已提交
199
@@ -932,6 +932,7 @@ export class FileDragAndDrop extends SimpleFileResourceDragAndDrop {
A
Asher 已提交
200 201 202
 	}
 
 	private handleExternalDrop(tree: ITree, data: DesktopDragAndDropData, target: ExplorerItem | Model, originalEvent: DragMouseEvent): TPromise<void> {
A
Asher 已提交
203
+		return (require('vs/../../../../packages/vscode') as typeof import ('vs/../../../../packages/vscode')).client.handleExternalDrop(target, originalEvent);
A
Asher 已提交
204 205 206
 		const droppedResources = extractResources(originalEvent.browserEvent as DragEvent, true);
 
 		// Check for dropped external files to be folders
K
Kyle Carberry 已提交
207
diff --git a/src/vs/workbench/parts/welcome/walkThrough/node/walkThroughContentProvider.ts b/src/vs/workbench/parts/welcome/walkThrough/node/walkThroughContentProvider.ts
A
Asher 已提交
208
index 7b4e8721ac..96d612f940 100644
K
Kyle Carberry 已提交
209 210
--- a/src/vs/workbench/parts/welcome/walkThrough/node/walkThroughContentProvider.ts
+++ b/src/vs/workbench/parts/welcome/walkThrough/node/walkThroughContentProvider.ts
A
Asher 已提交
211
@@ -28,14 +28,16 @@ export class WalkThroughContentProvider implements ITextModelContentProvider, IW
A
Asher 已提交
212
 	public provideTextContent(resource: URI): Thenable<ITextModel> {
K
Kyle Carberry 已提交
213
 		const query = resource.query ? JSON.parse(resource.query) : {};
A
Asher 已提交
214
 		const content: Thenable<string | ITextBufferFactory> = (query.moduleId ? new Promise<string>((resolve, reject) => {
K
Kyle Carberry 已提交
215
-			require([query.moduleId], content => {
A
Asher 已提交
216 217 218 219 220 221 222
-				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.
K
Kyle Carberry 已提交
223
+			import("vs/workbench/parts/welcome/page/electron-browser/vs_code_welcome_page").then((content) => {
A
Asher 已提交
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
+				resolve(content.default());
+			}).catch((err) => {
+				reject(err);
 			});
-		}) : 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)));
 		return content.then(content => {
 			let codeEditorModel = this.modelService.getModel(resource);
 			if (!codeEditorModel) {
@@ -61,7 +63,7 @@ export class WalkThroughSnippetContentProvider implements ITextModelContentProvi
 	}
 
 	public provideTextContent(resource: URI): Thenable<ITextModel> {
-		return this.textFileService.resolveTextContent(URI.file(resource.fsPath)).then(content => {
+		return fetch(resource.path).then((res) => res.text()).then((content) => {
 			let codeEditorModel = this.modelService.getModel(resource);
 			if (!codeEditorModel) {
 				const j = parseInt(resource.fragment);
@@ -78,17 +80,17 @@ export class WalkThroughSnippetContentProvider implements ITextModelContentProvi
 					return '';
 				};
 
-				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 });
 
 				const languageId = this.modeService.getModeIdForLanguageName(languageName);
 				const languageSelection = this.modeService.create(languageId);
 				codeEditorModel = this.modelService.createModel(codeSnippet, languageSelection, resource);
 			} else {
-				this.modelService.updateModel(codeEditorModel, content.value);
+				this.modelService.updateModel(codeEditorModel, content);
 			}
 
 			return codeEditorModel;
A
Asher 已提交
268
diff --git a/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts b/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts
A
Asher 已提交
269
index 4cb7a231f3..78c87d13f6 100644
A
Asher 已提交
270 271
--- a/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts
+++ b/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts
A
Asher 已提交
272
@@ -31,6 +31,7 @@ interface IExtensionCacheData {
A
Asher 已提交
273 274 275
 
 let _SystemExtensionsRoot: string | null = null;
 function getSystemExtensionsRoot(): string {
A
Asher 已提交
276
+	return (require('vs/../../../../packages/vscode') as typeof import ('vs/../../../../packages/vscode')).client.builtInExtensionsDirectory;
A
Asher 已提交
277 278 279
 	if (!_SystemExtensionsRoot) {
 		_SystemExtensionsRoot = path.normalize(path.join(getPathFromAmdModule(require, ''), '..', 'extensions'));
 	}
A
Asher 已提交
280 281 282 283 284 285 286 287 288 289 290 291 292
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
@@ -178,7 +178,7 @@ function _processIconThemeDocument(id: string, iconThemeDocumentLocation: URI, i
 
 	const iconThemeDocumentLocationDirname = resources.dirname(iconThemeDocumentLocation);
 	function resolvePath(path: string) {
-		return resources.joinPath(iconThemeDocumentLocationDirname, path);
+		return "/resource" + resources.joinPath(iconThemeDocumentLocationDirname, path).path;
 	}
 
 	function collectSelectors(associations: IconsAssociation, baseThemeClassName?: string) {