forked from coder/code-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvscode.patch
More file actions
8258 lines (7661 loc) · 385 KB
/
Copy pathvscode.patch
File metadata and controls
8258 lines (7661 loc) · 385 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/src/bootstrap-fork.js b/src/bootstrap-fork.js
index e30cadb0fc..120de744ca 100644
--- a/src/bootstrap-fork.js
+++ b/src/bootstrap-fork.js
@@ -19,6 +19,11 @@ if (!!process.send && process.env.PIPE_LOGGING === 'true') {
// Disable IO if configured
if (!process.env['VSCODE_ALLOW_IO']) {
disableSTDIO();
+} else {
+ process.stdin.resume();
+ process.stdin.on("close", () => {
+ process.exit(0);
+ });
}
// Handle Exceptions
diff --git a/src/vs/base/browser/ui/iconLabel/iconLabel.ts b/src/vs/base/browser/ui/iconLabel/iconLabel.ts
index 74be56db00..98e82ddd8a 100644
--- a/src/vs/base/browser/ui/iconLabel/iconLabel.ts
+++ b/src/vs/base/browser/ui/iconLabel/iconLabel.ts
@@ -122,7 +122,7 @@ export class IconLabel extends Disposable {
]);
}
- setValue(label?: string, description?: string, options?: IIconLabelValueOptions): void {
+ setValue(label?: string, description?: string, options?: IIconLabelValueOptions, element?: HTMLElement): void {
const classes = ['monaco-icon-label'];
if (options) {
if (options.extraClasses) {
@@ -161,6 +161,12 @@ export class IconLabel extends Disposable {
this.descriptionNode.empty = !description;
}
}
+
+ const oldElements = this.domNode.element.querySelectorAll(".decorations-wrapper");
+ oldElements.forEach((e) => e.remove());
+ if (element) {
+ this.domNode.element.appendChild(element);
+ }
}
}
diff --git a/src/vs/base/common/amd.ts b/src/vs/base/common/amd.ts
index 362a2e1e6f..64c7289377 100644
--- a/src/vs/base/common/amd.ts
+++ b/src/vs/base/common/amd.ts
@@ -8,5 +8,17 @@
import { URI } from 'vs/base/common/uri';
export function getPathFromAmdModule(requirefn: typeof require, relativePath: string): string {
+ requirefn.toUrl = () => {
+ return "";
+ };
+
+ // TODO@coder: Not sure if this is correct. Webpack makes things tricky.
+ if (process.mainModule && process.mainModule.filename) {
+ const index = process.mainModule.filename.lastIndexOf("/");
+ return process.mainModule.filename.slice(0, index);
+ }
+
+ return URI.parse("").fsPath;
+
return URI.parse(requirefn.toUrl(relativePath)).fsPath;
}
diff --git a/src/vs/base/common/labels.ts b/src/vs/base/common/labels.ts
index 41dd989c5f..012d265683 100644
--- a/src/vs/base/common/labels.ts
+++ b/src/vs/base/common/labels.ts
@@ -358,11 +358,14 @@ export function template(template: string, values: { [key: string]: string | ISe
* - macOS: Unsupported (replace && with empty string)
*/
export function mnemonicMenuLabel(label: string, forceDisableMnemonics?: boolean): string {
- if (isMacintosh || forceDisableMnemonics) {
- return label.replace(/\(&&\w\)|&&/g, '');
- }
+ // NOTE@coder: We could write some custom support for this. For now, disable.
+ return label.replace(/&&/g, '');
+
+ // if (isMacintosh || forceDisableMnemonics) {
+ // return label.replace(/\(&&\w\)|&&/g, '');
+ // }
- return label.replace(/&&/g, '&');
+ // return label.replace(/&&/g, '&');
}
/**
@@ -372,11 +375,14 @@ export function mnemonicMenuLabel(label: string, forceDisableMnemonics?: boolean
* - macOS: Unsupported (replace && with empty string)
*/
export function mnemonicButtonLabel(label: string): string {
- if (isMacintosh) {
- return label.replace(/\(&&\w\)|&&/g, '');
- }
+ // NOTE@coder: We could write some custom support for this. For now, disable.
+ return label.replace(/&&/g, '');
+
+ // if (isMacintosh) {
+ // return label.replace(/\(&&\w\)|&&/g, '');
+ // }
- return label.replace(/&&/g, isWindows ? '&' : '_');
+ // return label.replace(/&&/g, isWindows ? '&' : '_');
}
export function unmnemonicLabel(label: string): string {
diff --git a/src/vs/base/common/platform.ts b/src/vs/base/common/platform.ts
index fc6b2c285b..58d311c5bf 100644
--- a/src/vs/base/common/platform.ts
+++ b/src/vs/base/common/platform.ts
@@ -67,8 +67,11 @@ if (typeof process === 'object' && typeof process.nextTick === 'function' && typ
_isMacintosh = userAgent.indexOf('Macintosh') >= 0;
_isLinux = userAgent.indexOf('Linux') >= 0;
_isWeb = true;
- _locale = navigator.language;
+ // NOTE@coder: use en instead of en-US since that's vscode default and it uses
+ // that to determine whether to output aliases which will be pointless because
+ // they are the same language.
+ _locale = navigator.language === "en-US" ? "en" : navigator.language;
_language = _locale;
}
diff --git a/src/vs/base/common/winjs.polyfill.promise.ts b/src/vs/base/common/winjs.polyfill.promise.ts
index fb80ee9569..378aa7d689 100644
--- a/src/vs/base/common/winjs.polyfill.promise.ts
+++ b/src/vs/base/common/winjs.polyfill.promise.ts
@@ -73,6 +73,8 @@ export class PolyfillPromise<T = any> implements Promise<T> {
}
}
+ readonly [Symbol.toStringTag] = "Promise";
+
then(onFulfilled?: any, onRejected?: any): PolyfillPromise {
let sync = true;
// To support chaining, we need to return the value of the
@@ -126,4 +128,4 @@ export class PolyfillPromise<T = any> implements Promise<T> {
catch(onRejected?: any): PolyfillPromise {
return this.then(null, onRejected);
}
-}
+};
diff --git a/src/vs/base/node/config.ts b/src/vs/base/node/config.ts
index 31eea31a6b..67330b9db3 100644
--- a/src/vs/base/node/config.ts
+++ b/src/vs/base/node/config.ts
@@ -13,6 +13,7 @@ import { Event, Emitter } from 'vs/base/common/event';
import * as json from 'vs/base/common/json';
import * as extfs from 'vs/base/node/extfs';
import { isWindows } from 'vs/base/common/platform';
+import { isBrowserEnvironment } from 'coder/common';
export interface IConfigurationChangeEvent<T> {
config: T;
@@ -61,7 +62,7 @@ export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable {
this.disposables.push(this._onDidUpdateConfiguration);
this.registerWatcher();
- this.initAsync();
+ this.init();
}
public get path(): string {
@@ -76,15 +77,20 @@ export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable {
return this._onDidUpdateConfiguration.event;
}
- private initAsync(): void {
- this.loadAsync(config => {
+ private init(): void {
+ const callback = (config: T): void => {
if (!this.loaded) {
this.updateCache(config); // prevent race condition if config was loaded sync already
}
if (this.options.initCallback) {
this.options.initCallback(this.getConfig());
}
- });
+ };
+ if (isBrowserEnvironment()) {
+ this.loadAsync(callback);
+ } else {
+ this.loadSync(callback);
+ }
}
private updateCache(value: T): void {
@@ -92,11 +98,11 @@ export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable {
this.loaded = true;
}
- private loadSync(): T {
+ private loadSync(callback: (config: T) => void): void {
try {
- return this.parse(fs.readFileSync(this._path).toString());
+ callback(this.parse(fs.readFileSync(this._path).toString()));
} catch (error) {
- return this.options.defaultConfig;
+ callback(this.options.defaultConfig);
}
}
@@ -216,7 +222,12 @@ export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable {
private ensureLoaded(): void {
if (!this.loaded) {
- this.updateCache(this.loadSync());
+ // NOTE@coder: since loading asynchronously can sometimes take a while,
+ // this can come in, fail (since we can't support sync), then set itself
+ // to the default, which means the user's settings or keybinds don't take
+ // effect when the asynchronous call finally comes back.
+ // Commenting it out.
+ // this.updateCache(this.loadSync());
}
}
@@ -224,4 +235,4 @@ export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable {
this.disposed = true;
this.disposables = dispose(this.disposables);
}
-}
\ No newline at end of file
+}
diff --git a/src/vs/base/node/encoding.ts b/src/vs/base/node/encoding.ts
index d1ed967b22..b182c9f969 100644
--- a/src/vs/base/node/encoding.ts
+++ b/src/vs/base/node/encoding.ts
@@ -10,7 +10,8 @@ import * as iconv from 'iconv-lite';
import { TPromise } from 'vs/base/common/winjs.base';
import { isLinux, isMacintosh } from 'vs/base/common/platform';
import { exec } from 'child_process';
-import { Readable, Writable, WritableOptions } from 'stream';
+import { Readable, Transform, Writable, WritableOptions } from 'stream';
+import { IconvLiteDecoderStream } from './iconv';
export const UTF8 = 'utf8';
export const UTF8_with_bom = 'utf8bom';
@@ -132,7 +133,7 @@ export function encodingExists(encoding: string): boolean {
}
export function decodeStream(encoding: string): NodeJS.ReadWriteStream {
- return iconv.decodeStream(toNodeEncoding(encoding));
+ return new IconvLiteDecoderStream((iconv as any).getDecoder(encoding, undefined), undefined);
}
export function encodeStream(encoding: string, options?: { addBOM?: boolean }): NodeJS.ReadWriteStream {
diff --git a/src/vs/base/node/paths.ts b/src/vs/base/node/paths.ts
index 66930cdaf4..4f00a4982e 100644
--- a/src/vs/base/node/paths.ts
+++ b/src/vs/base/node/paths.ts
@@ -3,14 +3,14 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
-import { getPathFromAmdModule } from 'vs/base/common/amd';
+// import { getPathFromAmdModule } from 'vs/base/common/amd';
-interface IPaths {
- getAppDataPath(platform: string): string;
- getDefaultUserDataPath(platform: string): string;
-}
+// interface IPaths {
+// getAppDataPath(platform: string): string;
+// getDefaultUserDataPath(platform: string): string;
+// }
-const pathsPath = getPathFromAmdModule(require, 'paths');
-const paths = require.__$__nodeRequire<IPaths>(pathsPath);
-export const getAppDataPath = paths.getAppDataPath;
-export const getDefaultUserDataPath = paths.getDefaultUserDataPath;
+// const pathsPath = getPathFromAmdModule(require, 'paths');
+// const paths = require.__$__nodeRequire<IPaths>(pathsPath);
+export const getAppDataPath = () => "/tmp" // paths.getAppDataPath;
+export const getDefaultUserDataPath = (arg?: string) => "/tmp" // paths.getDefaultUserDataPath;
diff --git a/src/vs/base/parts/contextmenu/electron-main/contextmenu.ts b/src/vs/base/parts/contextmenu/electron-main/contextmenu.ts
index 5afeaad9c1..3529dbb97b 100644
--- a/src/vs/base/parts/contextmenu/electron-main/contextmenu.ts
+++ b/src/vs/base/parts/contextmenu/electron-main/contextmenu.ts
@@ -5,60 +5,46 @@
'use strict';
-import { Menu, MenuItem, BrowserWindow, Event, ipcMain } from 'electron';
+import { Event, ipcMain } from 'electron';
import { ISerializableContextMenuItem, CONTEXT_MENU_CLOSE_CHANNEL, CONTEXT_MENU_CHANNEL, IPopupOptions } from 'vs/base/parts/contextmenu/common/contextmenu';
+import { ContextMenuManager, ContextMenu } from 'coder/element/contextmenu';
+
+const manager = new ContextMenuManager();
export function registerContextMenuListener(): void {
ipcMain.on(CONTEXT_MENU_CHANNEL, (event: Event, items: ISerializableContextMenuItem[], onClickChannel: string, options?: IPopupOptions) => {
const menu = createMenu(event, onClickChannel, items);
- menu.popup({
- window: BrowserWindow.fromWebContents(event.sender),
- x: options ? options.x : void 0,
- y: options ? options.y : void 0,
- positioningItem: options ? options.positioningItem : void 0,
- callback: () => {
- event.sender.send(CONTEXT_MENU_CLOSE_CHANNEL);
- }
+ manager.displayMenuAtPoint(menu, {
+ top: options ? options.y : void 0,
+ left: options ? options.x : void 0,
+ });
+ manager.onceClose(() => {
+ event.sender.send(CONTEXT_MENU_CLOSE_CHANNEL);
});
});
}
-function createMenu(event: Event, onClickChannel: string, items: ISerializableContextMenuItem[]): Menu {
- const menu = new Menu();
+function createMenu(event: Event, onClickChannel: string, items: ISerializableContextMenuItem[]): ContextMenu {
+ const menu = new ContextMenu(onClickChannel, manager);
items.forEach(item => {
- let menuitem: MenuItem;
-
// Separator
if (item.type === 'separator') {
- menuitem = new MenuItem({
- type: item.type,
- });
+ menu.addSpacer(item.id);
}
// Sub Menu
else if (Array.isArray(item.submenu)) {
- menuitem = new MenuItem({
- submenu: createMenu(event, onClickChannel, item.submenu),
- label: item.label
- });
+ menu.addSubMenu(item.id, createMenu(event, onClickChannel, item.submenu), item.label);
}
// Normal Menu Item
else {
- menuitem = new MenuItem({
- label: item.label,
- type: item.type,
- accelerator: item.accelerator,
- checked: item.checked,
- enabled: item.enabled,
- visible: item.visible,
- click: (menuItem, win, contextmenuEvent) => event.sender.send(onClickChannel, item.id, contextmenuEvent)
+ menu.addEntry(item.id, item.label, item.accelerator, item.enabled, () => {
+ event.sender.send(onClickChannel, item.id);
});
}
-
- menu.append(menuitem);
});
return menu;
diff --git a/src/vs/base/parts/ipc/node/ipc.net.ts b/src/vs/base/parts/ipc/node/ipc.net.ts
index c802f0bd42..ea6ef313ac 100644
--- a/src/vs/base/parts/ipc/node/ipc.net.ts
+++ b/src/vs/base/parts/ipc/node/ipc.net.ts
@@ -5,6 +5,7 @@
'use strict';
+import { EventEmitter } from "events";
import { Socket, Server as NetServer, createConnection, createServer } from 'net';
import { Event, Emitter, once, mapEvent, fromNodeEventEmitter } from 'vs/base/common/event';
import { IMessagePassingProtocol, ClientConnectionEvent, IPCServer, IPCClient } from 'vs/base/parts/ipc/node/ipc';
@@ -13,6 +14,7 @@ import { tmpdir } from 'os';
import { generateUuid } from 'vs/base/common/uuid';
import { IDisposable } from 'vs/base/common/lifecycle';
import { TimeoutTimer } from 'vs/base/common/async';
+import { Session } from '../../../../../../../../wush/src/index';
export function generateRandomPipeName(): string {
const randomSuffix = generateUuid();
@@ -34,6 +36,100 @@ export function generateRandomPipeName(): string {
export class Protocol implements IDisposable, IMessagePassingProtocol {
+ public static fromSession(session: Session, onExit: (code: number) => void): Protocol {
+ session.onDone((exitCode) => onExit(exitCode));
+ return Protocol.fromStdio({
+ onMessage: (cb) => {
+ session.onStdout((data) => {
+ cb(Buffer.from(data as any));
+ }, true);
+ },
+ sendMessage: (data) => {
+ session.sendStdin(data);
+ },
+ });
+ }
+
+ public static fromStream(
+ inStream: { on: (event: "data", cb: (b: Buffer) => void) => void },
+ outStream: { write: (b: Buffer) => void },
+ ): Protocol {
+ return Protocol.fromStdio({
+ onMessage: (cb) => {
+ inStream.on("data", (data) => {
+ cb(Buffer.from(data));
+ });
+ },
+ sendMessage: (data: string) => {
+ outStream.write(Buffer.from(data));
+ },
+ });
+ }
+
+ public static fromWorker(worker: {
+ onmessage: (event: MessageEvent) => void;
+ postMessage: (data: string, origin?: string | string[]) => void;
+ }, ignoreFirst: boolean = false): Protocol {
+ return Protocol.fromStdio({
+ onMessage: (cb) => {
+ worker.onmessage = (event: MessageEvent) => {
+ cb(event.data);
+ };
+ },
+ sendMessage: (data: string) => {
+ worker.postMessage(data);
+ },
+ }, ignoreFirst);
+ }
+
+ public static fromStdio(stdio: {
+ onMessage: (cb: (data: string | Uint8Array) => void) => void;
+ sendMessage: (data: string | Uint8Array) => void;
+ }, ignoreFirst: boolean = false): Protocol {
+ return new Protocol(new (class WorkerSocket {
+
+ private readonly emitter: EventEmitter;
+
+ public constructor() {
+ this.emitter = new EventEmitter();
+
+ let first = true;
+ stdio.onMessage((data) => {
+ if (ignoreFirst && first) {
+ first = false;
+ return;
+ }
+ this.emitter.emit("data", typeof data === "string" ? data : Buffer.from(data as any));
+ });
+ }
+
+ public removeListener(event: string, listener: () => void): void {
+ this.emitter.removeListener(event, listener);
+ }
+
+ public once(event: string, listener: () => void): void {
+ this.emitter.once(event, listener);
+ }
+
+ public on(event: string, listener: () => void): void {
+ this.emitter.on(event, listener);
+ }
+
+ public end(): void {
+ // TODO: figure it out
+ }
+
+ public get destroyed() {
+ return false;
+ }
+
+ public write(data: any): void {
+ stdio.sendMessage(data);
+ }
+
+ }) as any);
+ }
+
private static readonly _headerLen = 4;
private _isDisposed: boolean;
diff --git a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts b/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts
index ff48ec7cb6..9c65419c8e 100644
--- a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts
+++ b/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts
@@ -6,7 +6,8 @@
'use strict';
import * as fs from 'fs';
-import * as platform from 'vs/base/common/platform';
+import { join } from 'path';
+// import * as platform from 'vs/base/common/platform';
import product from 'vs/platform/node/product';
import pkg from 'vs/platform/node/package';
import { serve, Server, connect } from 'vs/base/parts/ipc/node/ipc.net';
@@ -23,7 +24,9 @@ import { ExtensionGalleryService } from 'vs/platform/extensionManagement/node/ex
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ConfigurationService } from 'vs/platform/configuration/node/configurationService';
import { IRequestService } from 'vs/platform/request/node/request';
-import { RequestService } from 'vs/platform/request/electron-browser/requestService';
+// NOTE@coder: Use the node request instead of the xhr-based one.
+import { RequestService } from 'vs/platform/request/node/requestService';
+// import { RequestService } from 'vs/platform/request/electron-browser/requestService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { combinedAppender, NullTelemetryService, ITelemetryAppender, NullAppender, LogAppender } from 'vs/platform/telemetry/common/telemetryUtils';
import { resolveCommonProperties } from 'vs/platform/telemetry/node/commonProperties';
@@ -32,7 +35,7 @@ import { TelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry
import { AppInsightsAppender } from 'vs/platform/telemetry/node/appInsightsAppender';
import { IWindowsService, ActiveWindowManager } from 'vs/platform/windows/common/windows';
import { WindowsChannelClient } from 'vs/platform/windows/node/windowsIpc';
-import { ipcRenderer } from 'electron';
+// import { ipcRenderer } from 'electron';
import { createSharedProcessContributions } from 'vs/code/electron-browser/sharedProcess/contrib/contributions';
import { createSpdLogService } from 'vs/platform/log/node/spdlogService';
import { ILogService, LogLevel } from 'vs/platform/log/common/log';
@@ -46,13 +49,52 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IDownloadService } from 'vs/platform/download/common/download';
import { DownloadServiceChannelClient } from 'vs/platform/download/node/downloadIpc';
import { DefaultURITransformer } from 'vs/base/common/uriIpc';
+import { readdir, rimraf } from 'vs/base/node/pfs';
+
+// NOTE:@coder: provide ipcRenderer.
+const ipcRenderer = {
+ once: (_: string, cb: (_: any, r: IInitData) => void) => {
+ process.on('message', (message) => {
+ // Just going to assume the first message is the one we want for now.
+ const initData = JSON.parse(message) as IInitData;
+ process.env.VSCODE_LOGS = initData.logsDir;
+ product.extensionsGallery.serviceUrl = initData.serviceUrl;
+ // NOTE@coder: clean up old logs. This is mostly to reset the logs for the
+ // shared process itself and to account for logs sent after a shared
+ // client exits, but also cleans up logs that haven't been cleaned up due
+ // to an unexpected exit.
+ readdir(initData.logsDir)
+ .then((cs) => cs.filter((c) => !c.includes(`${initData.windowId}`)))
+ .then((cs) => TPromise.join(cs.map((c) => rimraf(join(initData.logsDir, c)))))
+ .then(() => cb(undefined, initData));
+ });
+ },
+ send: (message: string) => {
+ process.send(message);
+ },
+};
+
+// NOTE@coder: custom data for initialization.
+export interface IInitData extends ISharedProcessInitData {
+ serviceUrl: string;
+ logsDir: string;
+ windowId: number;
+}
+
+// NOTE@coder: start immediately.
+startup({
+ machineId: "1",
+});
export interface ISharedProcessConfiguration {
readonly machineId: string;
}
export function startup(configuration: ISharedProcessConfiguration) {
- handshake(configuration);
+ // NOTE:@coder: exit on error.
+ handshake(configuration).then(null, (error) => {
+ process.exit(1);
+ });
}
interface ISharedProcessInitData {
diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts
index 4ade1e0175..549b95ca34 100644
--- a/src/vs/code/electron-main/app.ts
+++ b/src/vs/code/electron-main/app.ts
@@ -14,7 +14,7 @@ import { WindowsService } from 'vs/platform/windows/electron-main/windowsService
import { ILifecycleService } from 'vs/platform/lifecycle/electron-main/lifecycleMain';
import { getShellEnvironment } from 'vs/code/node/shellEnv';
import { IUpdateService } from 'vs/platform/update/common/update';
-import { UpdateChannel } from 'vs/platform/update/node/updateIpc';
+// import { UpdateChannel } from 'vs/platform/update/node/updateIpc';
import { Server as ElectronIPCServer } from 'vs/base/parts/ipc/electron-main/ipc.electron-main';
import { Server, connect, Client } from 'vs/base/parts/ipc/node/ipc.net';
import { SharedProcess } from 'vs/code/electron-main/sharedProcess';
@@ -192,7 +192,7 @@ export class CodeApplication {
macOpenFileURIs = [];
runningTimeout = null;
}
- }, 100);
+ }, 100) as any;
});
app.on('new-window-for-tab', () => {
@@ -427,9 +427,9 @@ export class CodeApplication {
this.mainIpcServer.registerChannel('launch', launchChannel);
// Register more Electron IPC services
- const updateService = accessor.get(IUpdateService);
- const updateChannel = new UpdateChannel(updateService);
- this.electronIpcServer.registerChannel('update', updateChannel);
+ // const updateService = accessor.get(IUpdateService);
+ // const updateChannel = new UpdateChannel(updateService);
+ // this.electronIpcServer.registerChannel('update', updateChannel);
const issueService = accessor.get(IIssueService);
const issueChannel = new IssueChannel(issueService);
diff --git a/src/vs/editor/browser/services/codeEditorServiceImpl.ts b/src/vs/editor/browser/services/codeEditorServiceImpl.ts
index 7b006da43e..d69df8f07f 100644
--- a/src/vs/editor/browser/services/codeEditorServiceImpl.ts
+++ b/src/vs/editor/browser/services/codeEditorServiceImpl.ts
@@ -433,7 +433,8 @@ class DecorationCSSRules {
if (typeof opts.gutterIconPath !== 'undefined') {
if (typeof opts.gutterIconPath === 'string') {
- cssTextArr.push(strings.format(_CSS_MAP.gutterIconPath, URI.file(opts.gutterIconPath).toString()));
+ // NOTE@coder: change file() to parse() to allow HTTP URIs.
+ cssTextArr.push(strings.format(_CSS_MAP.gutterIconPath, URI.parse(opts.gutterIconPath).toString()));
} else {
cssTextArr.push(strings.format(_CSS_MAP.gutterIconPath, URI.revive(opts.gutterIconPath).toString(true).replace(/'/g, '%27')));
}
diff --git a/src/vs/editor/common/model/textModel.ts b/src/vs/editor/common/model/textModel.ts
index 5df5b9eca1..77b0d0e6c0 100644
--- a/src/vs/editor/common/model/textModel.ts
+++ b/src/vs/editor/common/model/textModel.ts
@@ -71,6 +71,9 @@ export function createTextBufferFactoryFromStream(stream: IStringStream, filter?
c(builder.finish());
}
});
+ // We know internally we're passing this an EventEmitter.
+ // Definitely not the best way to handle this.
+ (stream as any).emit('ready');
});
}
diff --git a/src/vs/editor/contrib/clipboard/clipboard.ts b/src/vs/editor/contrib/clipboard/clipboard.ts
index 4d0ec22210..acdf47482f 100644
--- a/src/vs/editor/contrib/clipboard/clipboard.ts
+++ b/src/vs/editor/contrib/clipboard/clipboard.ts
@@ -18,6 +18,10 @@ import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { MenuId } from 'vs/platform/actions/common/actions';
+import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
+import { Handler } from 'vs/editor/common/editorCommon';
+import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
+import { nativeClipboard } from 'coder/workbench';
const CLIPBOARD_CONTEXT_MENU_GROUP = '9_cutcopypaste';
@@ -28,7 +32,7 @@ const supportsCopyWithSyntaxHighlighting = (supportsCopy && !browser.isEdgeOrIE)
// 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 = true;
type ExecCommand = 'cut' | 'copy' | 'paste';
@@ -166,7 +170,7 @@ class ExecCommandPasteAction extends ExecCommandAction {
id: 'editor.action.clipboardPasteAction',
label: nls.localize('actions.clipboard.pasteLabel', "Paste"),
alias: 'Paste',
- precondition: EditorContextKeys.writable,
+ precondition: ContextKeyExpr.and(EditorContextKeys.writable, nativeClipboard.contextKey),
kbOpts: kbOpts,
menuOpts: {
group: CLIPBOARD_CONTEXT_MENU_GROUP,
@@ -180,6 +184,20 @@ class ExecCommandPasteAction extends ExecCommandAction {
}
});
}
+
+ public async run(accessor, editor: ICodeEditor): Promise<void> {
+ if (editor instanceof CodeEditorWidget) {
+ try {
+ editor.trigger('', Handler.Paste, {
+ text: await nativeClipboard.instance.readText(),
+ });
+ } catch (ex) {
+ super.run(accessor, editor);
+ }
+ } else {
+ super.run(accessor, editor);
+ }
+ }
}
class ExecCommandCopyWithSyntaxHighlightingAction extends ExecCommandAction {
diff --git a/src/vs/loader.js b/src/vs/loader.js
index d02070659c..de85aefcdb 100644
--- a/src/vs/loader.js
+++ b/src/vs/loader.js
@@ -652,10 +652,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');
// js-flags have an impact on cached data
this._jsflags = '';
for (var _i = 0, _a = process.argv; _i < _a.length; _i++) {
@@ -725,11 +725,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);
@@ -823,14 +830,14 @@ var AMDLoader;
path: cachedDataPath
});
NodeScriptLoader._runSoon(function () { return _this._fs.unlink(cachedDataPath, function (err) {
- if (err) {
- moduleManager.getConfig().getOptionsLiteral().onNodeCachedData({
- errorCode: 'unlink',
- path: cachedDataPath,
- detail: err
- });
- }
- }); }, moduleManager.getConfig().getOptionsLiteral().nodeCachedDataWriteDelay);
+ if (err) {
+ moduleManager.getConfig().getOptionsLiteral().onNodeCachedData({
+ errorCode: 'unlink',
+ path: cachedDataPath,
+ detail: err
+ });
+ }
+ }); }, moduleManager.getConfig().getOptionsLiteral().nodeCachedDataWriteDelay);
}
else if (script.cachedDataProduced) {
// data produced => tell outside world
@@ -840,14 +847,14 @@ var AMDLoader;
});
// data produced => write cache file
NodeScriptLoader._runSoon(function () { return _this._fs.writeFile(cachedDataPath, script.cachedData, function (err) {
- if (err) {
- moduleManager.getConfig().getOptionsLiteral().onNodeCachedData({
- errorCode: 'writeFile',
- path: cachedDataPath,
- detail: err
- });
- }
- }); }, moduleManager.getConfig().getOptionsLiteral().nodeCachedDataWriteDelay);
+ if (err) {
+ moduleManager.getConfig().getOptionsLiteral().onNodeCachedData({
+ errorCode: 'writeFile',
+ path: cachedDataPath,
+ detail: err
+ });
+ }
+ }); }, moduleManager.getConfig().getOptionsLiteral().nodeCachedDataWriteDelay);
}
};
NodeScriptLoader._runSoon = function (callback, minTimeout) {
diff --git a/src/vs/platform/actions/browser/menuItemActionItem.ts b/src/vs/platform/actions/browser/menuItemActionItem.ts
index a4ef78d6f0..eaa348e689 100644
--- a/src/vs/platform/actions/browser/menuItemActionItem.ts
+++ b/src/vs/platform/actions/browser/menuItemActionItem.ts
@@ -18,6 +18,7 @@ import { ICommandAction, IMenu, IMenuActionOptions, MenuItemAction, SubmenuItemA
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { INotificationService } from 'vs/platform/notification/common/notification';
+import { getFetchUri } from 'coder/api';
// The alternative key on all platforms is alt. On windows we also support shift as an alternative key #44136
class AlternativeKeyEmitter extends Emitter<boolean> {
@@ -231,8 +232,8 @@ export class MenuItemActionItem extends ActionItem {
iconClass = MenuItemActionItem.ICON_PATH_TO_CSS_RULES.get(iconPathMapKey);
} else {
iconClass = ids.nextId();
- createCSSRule(`.icon.${iconClass}`, `background-image: url("${(item.iconLocation.light || item.iconLocation.dark).toString()}")`);
- createCSSRule(`.vs-dark .icon.${iconClass}, .hc-black .icon.${iconClass}`, `background-image: url("${item.iconLocation.dark.toString()}")`);
+ createCSSRule(`.icon.${iconClass}`, `background-image: url("${(getFetchUri(item.iconLocation.light || item.iconLocation.dark)).toString(true)}")`);
+ createCSSRule(`.vs-dark .icon.${iconClass}, .hc-black .icon.${iconClass}`, `background-image: url("${getFetchUri(item.iconLocation.dark).toString(true)}")`);
MenuItemActionItem.ICON_PATH_TO_CSS_RULES.set(iconPathMapKey, iconClass);
}
diff --git a/src/vs/platform/configuration/node/configuration.ts b/src/vs/platform/configuration/node/configuration.ts
index 925ea03a57..44207f8afa 100644
--- a/src/vs/platform/configuration/node/configuration.ts
+++ b/src/vs/platform/configuration/node/configuration.ts
@@ -9,23 +9,30 @@ import { ConfigurationModelParser, ConfigurationModel } from 'vs/platform/config
import { ConfigWatcher } from 'vs/base/node/config';
import { Event, Emitter } from 'vs/base/common/event';
import { TPromise } from 'vs/base/common/winjs.base';
+import { isBrowserEnvironment } from 'coder/common';
export class UserConfiguration extends Disposable {
private userConfigModelWatcher: ConfigWatcher<ConfigurationModelParser>;
private readonly _onDidChangeConfiguration: Emitter<ConfigurationModel> = this._register(new Emitter<ConfigurationModel>());
+ private readonly loadPromise: Promise<void>;
readonly onDidChangeConfiguration: Event<ConfigurationModel> = this._onDidChangeConfiguration.event;
constructor(settingsPath: string) {
super();
+ let initRes: () => void;
+ this.loadPromise = new Promise((r) => initRes = r);
this.userConfigModelWatcher = new ConfigWatcher(settingsPath, {
changeBufferDelay: 300, onError: error => onUnexpectedError(error), defaultConfig: new ConfigurationModelParser(settingsPath), parse: (content: string, parseErrors: any[]) => {
const userConfigModelParser = new ConfigurationModelParser(settingsPath);
userConfigModelParser.parse(content);
parseErrors = [...userConfigModelParser.errors];
return userConfigModelParser;
- }
+ },
+ initCallback: isBrowserEnvironment ? () => {
+ initRes();
+ } : undefined,
});
this._register(this.userConfigModelWatcher);
@@ -37,6 +44,10 @@ export class UserConfiguration extends Disposable {
return this.userConfigModelWatcher.getConfig().configurationModel;
}
+ get loaded(): Promise<void> {
+ return this.loadPromise;
+ }
+
reload(): TPromise<void> {
return new TPromise(c => this.userConfigModelWatcher.reload(() => c(null)));
}
diff --git a/src/vs/platform/dialogs/node/dialogService.ts b/src/vs/platform/dialogs/node/dialogService.ts
index 4304af5518..b12d48b18d 100644
--- a/src/vs/platform/dialogs/node/dialogService.ts
+++ b/src/vs/platform/dialogs/node/dialogService.ts
@@ -3,13 +3,15 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
-import * as readline from 'readline';
+// import * as readline from 'readline';
import { TPromise } from 'vs/base/common/winjs.base';
import { IDialogService, IConfirmation, IConfirmationResult } from 'vs/platform/dialogs/common/dialogs';
import Severity from 'vs/base/common/severity';
import { localize } from 'vs/nls';
import { canceled } from 'vs/base/common/errors';
+declare var readline: any;
+
export class CommandLineDialogService implements IDialogService {
_serviceBrand: any;
diff --git a/src/vs/platform/extensionManagement/common/extensionManagement.ts b/src/vs/platform/extensionManagement/common/extensionManagement.ts
index ee381bbe35..698076bb89 100644
--- a/src/vs/platform/extensionManagement/common/extensionManagement.ts
+++ b/src/vs/platform/extensionManagement/common/extensionManagement.ts
@@ -188,6 +188,7 @@ export interface IGalleryExtension {
publisherDisplayName: string;
description: string;
installCount: number;
+ stars: number;
rating: number;
ratingCount: number;
assets: IGalleryExtensionAssets;
diff --git a/src/vs/platform/extensionManagement/node/extensionGalleryService.ts b/src/vs/platform/extensionManagement/node/extensionGalleryService.ts
index ce457e5e9f..ee73e348a6 100644
--- a/src/vs/platform/extensionManagement/node/extensionGalleryService.ts
+++ b/src/vs/platform/extensionManagement/node/extensionGalleryService.ts
@@ -103,7 +103,7 @@ enum FilterType {
ExcludeWithFlags = 12
}
-const AssetType = {
+export const AssetType = {
Icon: 'Microsoft.VisualStudio.Services.Icons.Default',
Details: 'Microsoft.VisualStudio.Services.Content.Details',
Changelog: 'Microsoft.VisualStudio.Services.Content.Changelog',
@@ -311,6 +311,7 @@ function toExtension(galleryExtension: IRawGalleryExtension, version: IRawGaller
publisherDisplayName: galleryExtension.publisher.displayName,
description: galleryExtension.shortDescription || '',
installCount: getStatistic(galleryExtension.statistics, 'install') + getStatistic(galleryExtension.statistics, 'updateCount'),
+ stars: getStatistic(galleryExtension.statistics, 'stars'),
rating: getStatistic(galleryExtension.statistics, 'averagerating'),
ratingCount: getStatistic(galleryExtension.statistics, 'ratingcount'),
assets,
@@ -474,29 +475,104 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
private queryGallery(query: Query, token: CancellationToken): TPromise<{ galleryExtensions: IRawGalleryExtension[], total: number; }> {
return this.commonHeadersPromise.then(commonHeaders => {
const data = JSON.stringify(query.raw);
- const headers = assign({}, commonHeaders, {
+ const headers = assign({}, {}, {
'Content-Type': 'application/json',
'Accept': 'application/json;api-version=3.0-preview.1',
'Accept-Encoding': 'gzip',
'Content-Length': data.length
});
+ let ids: string[];
+ try {
+ const criteria = query.raw.filters[0].criteria;
+ const newIds = [];
+ for (let i = 0; i < criteria.length; i++) {
+ const crit = criteria[i];
+ if (crit.filterType === FilterType.ExtensionName) {
+ newIds.push(crit.value);
+ }
+ }
+ if (newIds.length > 0) {
+ ids = newIds;
+ }
+ } catch (ex) {
+
+ }
+
+ const queryString = `?${query.searchText ? `name=${query.searchText}&` : ""}page=${query.pageNumber - 1}&page_size=${query.pageSize}&sort=downloads${ids ? `&${ids.map((id) => `id=${id}`).join("&")}` : ""}`
+
return this.requestService.request({
- type: 'POST',
- url: this.api('/extensionquery'),
+ type: 'GET',
+ url: this.api(`/search${queryString}`),
data,
- headers
}, token).then(context => {
if (context.res.statusCode >= 400 && context.res.statusCode < 500) {
return { galleryExtensions: [], total: 0 };
}
- return asJson<IRawGalleryQueryResult>(context).then(result => {
- const r = result.results[0];
- const galleryExtensions = r.extensions;
- const resultCount = r.resultMetadata && r.resultMetadata.filter(m => m.metadataType === 'ResultCount')[0];
- const total = resultCount && resultCount.metadataItems.filter(i => i.name === 'TotalCount')[0].count || 0;
+ return asJson<any>(context).then((result: Array<{
+ readonly author: string;
+ readonly category: string;
+ readonly downloads: number;
+ readonly forks: number;
+ readonly id: string;
+ readonly name: string;
+ readonly short_description: string;
+ readonly source_url: string;
+ readonly stars: number;
+ readonly version: string;
+ readonly watchers: number;
+ readonly metadata: {
+ readonly files: IRawGalleryExtensionFile[];
+ readonly properties: IRawGalleryExtensionProperty[];
+ }
+ }>) => {
+
+ const galleryExtensions: IRawGalleryExtension[] = result.filter((ext) => ext.metadata).map((ext): IRawGalleryExtension => {
+ const assetUrl = ext.source_url.replace("/Microsoft.VisualStudio.Services.VSIXPackage", "");
+
+ return {
+ displayName: ext.name,
+ extensionId: ext.id,
+ extensionName: ext.id,
+ flags: "",
+ publisher: {
+ displayName: ext.author,
+ publisherId: undefined,
+ publisherName: ext.author,
+ },
+ shortDescription: ext.short_description,
+ statistics: [{
+ statisticName: 'stars',
+ value: ext.stars,
+ }, {
+ statisticName: 'forks',
+ value: ext.forks,
+ }, {
+ statisticName: 'watchers',
+ value: ext.watchers,
+ }, {
+ statisticName: 'install',
+ value: ext.downloads,
+ }],
+ versions: [{
+ assetUri: assetUrl,
+ fallbackAssetUri: assetUrl,
+ files: [
+ ...ext.metadata.files,
+ {
+ assetType: AssetType.VSIX,
+ source: ext.source_url,
+ },
+ ],
+ properties: ext.metadata.properties,
+ version: ext.version,
+ lastUpdated: undefined,
+ }],
+ };
+ });
+ const total = result.filter(ext => ext.metadata).length;