Skip to content

Commit 3da939d

Browse files
author
Benjamin Pasero
committed
Merge branch 'master' into ben/sandbox-environment
2 parents b2acd8f + 45c70c2 commit 3da939d

26 files changed

Lines changed: 177 additions & 63 deletions

File tree

build/lib/i18n.resources.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@
9494
"name": "vs/workbench/contrib/issue",
9595
"project": "vscode-workbench"
9696
},
97+
{
98+
"name": "vs/workbench/contrib/keybindings",
99+
"project": "vscode-workbench"
100+
},
97101
{
98102
"name": "vs/workbench/contrib/markers",
99103
"project": "vscode-workbench"

extensions/configuration-editing/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"url": "vscode://schemas/keybindings"
5555
},
5656
{
57-
"fileMatch": "vscode://defaultsettings/*/*.json",
57+
"fileMatch": "vscode://defaultsettings/*.json",
5858
"url": "vscode://schemas/settings/default"
5959
},
6060
{

extensions/github/src/publish.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ export async function publishRepository(gitAPI: GitAPI, repository?: Repository)
123123
try {
124124
quickpick.busy = true;
125125

126-
const children = (await vscode.workspace.fs.readDirectory(folder)).map(([name]) => name);
126+
const children = (await vscode.workspace.fs.readDirectory(folder))
127+
.map(([name]) => name)
128+
.filter(name => name !== '.git');
129+
127130
quickpick.items = children.map(name => ({ label: name }));
128131
quickpick.selectedItems = quickpick.items;
129132
quickpick.busy = false;

resources/web/code-web.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const args = minimist(process.argv, {
3636
'help',
3737
'verbose',
3838
'wrap-iframe',
39-
'enable-sync'
39+
'enable-sync',
40+
'trusted-types'
4041
],
4142
string: [
4243
'scheme',
@@ -53,6 +54,7 @@ if (args.help) {
5354
'yarn web [options]\n' +
5455
' --no-launch Do not open VSCode web in the browser\n' +
5556
' --wrap-iframe Wrap the Web Worker Extension Host in an iframe\n' +
57+
' --trusted-types Enable trusted types (report only)\n' +
5658
' --enable-sync Enable sync by default\n' +
5759
' --scheme Protocol (https or http)\n' +
5860
' --host Remote host\n' +
@@ -396,7 +398,13 @@ async function handleRoot(req, res) {
396398
.replace('{{WEBVIEW_ENDPOINT}}', '')
397399
.replace('{{REMOTE_USER_DATA_URI}}', '');
398400

399-
res.writeHead(200, { 'Content-Type': 'text/html' });
401+
402+
const headers = { 'Content-Type': 'text/html' };
403+
if (args['trusted-types']) {
404+
headers['Content-Security-Policy-Report-Only'] = 'require-trusted-types-for \'script\';';
405+
}
406+
407+
res.writeHead(200, headers);
400408
return res.end(data);
401409
}
402410

src/vs/base/parts/ipc/common/ipc.net.ts

Lines changed: 65 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,53 @@ class Queue<T> {
533533
}
534534
}
535535

536+
class LoadEstimator {
537+
538+
private static _HISTORY_LENGTH = 10;
539+
private static _INSTANCE: LoadEstimator | null = null;
540+
public static getInstance(): LoadEstimator {
541+
if (!LoadEstimator._INSTANCE) {
542+
LoadEstimator._INSTANCE = new LoadEstimator();
543+
}
544+
return LoadEstimator._INSTANCE;
545+
}
546+
547+
private lastRuns: number[];
548+
549+
constructor() {
550+
this.lastRuns = [];
551+
const now = Date.now();
552+
for (let i = 0; i < LoadEstimator._HISTORY_LENGTH; i++) {
553+
this.lastRuns[i] = now - 1000 * i;
554+
}
555+
setInterval(() => {
556+
for (let i = LoadEstimator._HISTORY_LENGTH; i >= 1; i--) {
557+
this.lastRuns[i] = this.lastRuns[i - 1];
558+
}
559+
this.lastRuns[0] = Date.now();
560+
}, 1000);
561+
}
562+
563+
/**
564+
* returns an estimative number, from 0 (low load) to 1 (high load)
565+
*/
566+
public load(): number {
567+
const now = Date.now();
568+
const historyLimit = (1 + LoadEstimator._HISTORY_LENGTH) * 1000;
569+
let score = 0;
570+
for (let i = 0; i < LoadEstimator._HISTORY_LENGTH; i++) {
571+
if (now - this.lastRuns[i] <= historyLimit) {
572+
score++;
573+
}
574+
}
575+
return 1 - score / LoadEstimator._HISTORY_LENGTH;
576+
}
577+
578+
public hasHighLoad(): boolean {
579+
return this.load() >= 0.5;
580+
}
581+
}
582+
536583
/**
537584
* Same as Protocol, but will actually track messages and acks.
538585
* Moreover, it will ensure no messages are lost if there are no event listeners.
@@ -559,6 +606,8 @@ export class PersistentProtocol implements IMessagePassingProtocol {
559606
private _socketReader: ProtocolReader;
560607
private _socketDisposables: IDisposable[];
561608

609+
private readonly _loadEstimator = LoadEstimator.getInstance();
610+
562611
private readonly _onControlMessage = new BufferedEmitter<VSBuffer>();
563612
readonly onControlMessage: Event<VSBuffer> = this._onControlMessage.event;
564613

@@ -670,15 +719,19 @@ export class PersistentProtocol implements IMessagePassingProtocol {
670719

671720
const timeSinceLastIncomingMsg = Date.now() - this._socketReader.lastReadTime;
672721
if (timeSinceLastIncomingMsg >= ProtocolConstants.KeepAliveTimeoutTime) {
673-
// Trash the socket
674-
this._onSocketTimeout.fire(undefined);
675-
return;
722+
// It's been a long time since we received a server message
723+
// But this might be caused by the event loop being busy and failing to read messages
724+
if (!this._loadEstimator.hasHighLoad()) {
725+
// Trash the socket
726+
this._onSocketTimeout.fire(undefined);
727+
return;
728+
}
676729
}
677730

678731
this._incomingKeepAliveTimeout = setTimeout(() => {
679732
this._incomingKeepAliveTimeout = null;
680733
this._recvKeepAliveCheck();
681-
}, ProtocolConstants.KeepAliveTimeoutTime - timeSinceLastIncomingMsg + 5);
734+
}, Math.max(ProtocolConstants.KeepAliveTimeoutTime - timeSinceLastIncomingMsg, 0) + 5);
682735
}
683736

684737
public getSocket(): ISocket {
@@ -821,15 +874,19 @@ export class PersistentProtocol implements IMessagePassingProtocol {
821874
const oldestUnacknowledgedMsg = this._outgoingUnackMsg.peek()!;
822875
const timeSinceOldestUnacknowledgedMsg = Date.now() - oldestUnacknowledgedMsg.writtenTime;
823876
if (timeSinceOldestUnacknowledgedMsg >= ProtocolConstants.AcknowledgeTimeoutTime) {
824-
// Trash the socket
825-
this._onSocketTimeout.fire(undefined);
826-
return;
877+
// It's been a long time since our sent message was acknowledged
878+
// But this might be caused by the event loop being busy and failing to read messages
879+
if (!this._loadEstimator.hasHighLoad()) {
880+
// Trash the socket
881+
this._onSocketTimeout.fire(undefined);
882+
return;
883+
}
827884
}
828885

829886
this._outgoingAckTimeout = setTimeout(() => {
830887
this._outgoingAckTimeout = null;
831888
this._recvAckCheck();
832-
}, ProtocolConstants.AcknowledgeTimeoutTime - timeSinceOldestUnacknowledgedMsg + 5);
889+
}, Math.max(ProtocolConstants.AcknowledgeTimeoutTime - timeSinceOldestUnacknowledgedMsg, 0) + 5);
833890
}
834891

835892
private _sendAck(): void {

src/vs/code/browser/workbench/workbench.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,13 @@ class WindowIndicator implements IWindowIndicator {
440440
// Find credentials from DOM
441441
const credentialsElement = document.getElementById('vscode-workbench-credentials');
442442
const credentialsElementAttribute = credentialsElement ? credentialsElement.getAttribute('data-settings') : undefined;
443-
const credentialsProvider = new LocalStorageCredentialsProvider(credentialsElementAttribute ? JSON.parse(credentialsElementAttribute) : []);
443+
let credentials = undefined;
444+
if (credentialsElementAttribute) {
445+
try {
446+
credentials = JSON.parse(credentialsElementAttribute);
447+
} catch (error) { /* Invalid credentials are passed. Ignore. */ }
448+
}
449+
const credentialsProvider = new LocalStorageCredentialsProvider(credentials || []);
444450

445451
// Finally create workbench
446452
create(document.body, {

src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ registerThemingParticipant((theme, collector) => {
358358
if (!caretBackground) {
359359
caretBackground = caret.opposite();
360360
}
361-
collector.addRule(`.monaco-editor .cursor { background-color: ${caret}; border-color: ${caret}; color: ${caretBackground}; }`);
361+
collector.addRule(`.monaco-editor .cursors-layer .cursor { background-color: ${caret}; border-color: ${caret}; color: ${caretBackground}; }`);
362362
if (theme.type === 'hc') {
363363
collector.addRule(`.monaco-editor .cursors-layer.has-selection .cursor { border-left: 1px solid ${caretBackground}; border-right: 1px solid ${caretBackground}; }`);
364364
}

src/vs/platform/keybinding/common/abstractKeybindingService.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ export abstract class AbstractKeybindingService extends Disposable implements IK
8181
protected _log(str: string): void {
8282
if (this._logging) {
8383
this._logService.info(`[KeybindingService]: ${str}`);
84-
} else {
85-
this._logService.trace(`[KeybindingService]: ${str}`);
8684
}
8785
}
8886

src/vs/workbench/api/browser/mainThreadAuthentication.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { fromNow } from 'vs/base/common/date';
2020
import { ActivationKind, IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
2121
import { Platform, platform } from 'vs/base/common/platform';
2222

23-
const VSO_ALLOWED_EXTENSIONS = ['github.vscode-pull-request-github', 'github.vscode-pull-request-github-insiders', 'vscode.git', 'ms-vsonline.vsonline', 'vscode.github-browser'];
23+
const VSO_ALLOWED_EXTENSIONS = ['github.vscode-pull-request-github', 'github.vscode-pull-request-github-insiders', 'vscode.git', 'ms-vsonline.vsonline', 'vscode.github-browser', 'ms-vscode.github-browser'];
2424

2525
interface IAccountUsage {
2626
extensionId: string;

src/vs/workbench/browser/actions/developerActions.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,6 @@ configurationRegistry.registerConfiguration({
324324
type: 'string',
325325
format: 'color-hex',
326326
default: '#FF0000',
327-
minLength: 4,
328-
maxLength: 9,
329327
description: nls.localize('screencastMode.mouseIndicatorColor', "Controls the color in hex (#RGB, #RGBA, #RRGGBB or #RRGGBBAA) of the mouse indicator in screencast mode.")
330328
},
331329
'screencastMode.mouseIndicatorSize': {

0 commit comments

Comments
 (0)