Merge VS Code 1.21 source code (#1067)

* Initial VS Code 1.21 file copy with patches

* A few more merges

* Post npm install

* Fix batch of build breaks

* Fix more build breaks

* Fix more build errors

* Fix more build breaks

* Runtime fixes 1

* Get connection dialog working with some todos

* Fix a few packaging issues

* Copy several node_modules to package build to fix loader issues

* Fix breaks from master

* A few more fixes

* Make tests pass

* First pass of license header updates

* Second pass of license header updates

* Fix restore dialog issues

* Remove add additional themes menu items

* fix select box issues where the list doesn't show up

* formatting

* Fix editor dispose issue

* Copy over node modules to correct location on all platforms
This commit is contained in:
Karl Burtram
2018-04-04 15:27:51 -07:00
committed by GitHub
parent 5fba3e31b4
commit dafb780987
9412 changed files with 141255 additions and 98813 deletions

View File

@@ -10,44 +10,58 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { ExtHostDocuments } from 'vs/workbench/api/node/extHostDocuments';
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/node/extHostDocumentsAndEditors';
import { TextDocumentSaveReason, TextEdit, Position, EndOfLine } from 'vs/workbench/api/node/extHostTypes';
import { MainThreadEditorsShape, IWorkspaceResourceEdit } from 'vs/workbench/api/node/extHost.protocol';
import { MainThreadTextEditorsShape, WorkspaceEditDto } from 'vs/workbench/api/node/extHost.protocol';
import { ExtHostDocumentSaveParticipant } from 'vs/workbench/api/node/extHostDocumentSaveParticipant';
import { OneGetThreadService } from './testThreadService';
import { SingleProxyRPCProtocol } from './testRPCProtocol';
import { SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
import * as vscode from 'vscode';
import { mock } from 'vs/workbench/test/electron-browser/api/mock';
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
import { NullLogService } from 'vs/platform/log/common/log';
import { isResourceTextEdit, ResourceTextEdit } from 'vs/editor/common/modes';
suite('ExtHostDocumentSaveParticipant', () => {
let resource = URI.parse('foo:bar');
let mainThreadEditors = new class extends mock<MainThreadEditorsShape>() { };
let mainThreadEditors = new class extends mock<MainThreadTextEditorsShape>() { };
let documents: ExtHostDocuments;
let nullLogService = new NullLogService();
let nullExtensionDescription: IExtensionDescription = {
id: 'nullExtensionDescription',
name: 'Null Extension Description',
publisher: 'vscode',
enableProposedApi: false,
engines: undefined,
extensionFolderPath: undefined,
isBuiltin: false,
version: undefined
};
setup(() => {
const documentsAndEditors = new ExtHostDocumentsAndEditors(OneGetThreadService(null));
const documentsAndEditors = new ExtHostDocumentsAndEditors(SingleProxyRPCProtocol(null));
documentsAndEditors.$acceptDocumentsAndEditorsDelta({
addedDocuments: [{
isDirty: false,
modeId: 'foo',
url: resource,
uri: resource,
versionId: 1,
lines: ['foo'],
EOL: '\n',
}]
});
documents = new ExtHostDocuments(OneGetThreadService(null), documentsAndEditors);
documents = new ExtHostDocuments(SingleProxyRPCProtocol(null), documentsAndEditors);
});
test('no listeners, no problem', () => {
const participant = new ExtHostDocumentSaveParticipant(documents, mainThreadEditors);
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, mainThreadEditors);
return participant.$participateInSave(resource, SaveReason.EXPLICIT).then(() => assert.ok(true));
});
test('event delivery', () => {
const participant = new ExtHostDocumentSaveParticipant(documents, mainThreadEditors);
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, mainThreadEditors);
let event: vscode.TextDocumentWillSaveEvent;
let sub = participant.onWillSaveTextDocumentEvent(function (e) {
let sub = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {
event = e;
});
@@ -61,10 +75,10 @@ suite('ExtHostDocumentSaveParticipant', () => {
});
test('event delivery, immutable', () => {
const participant = new ExtHostDocumentSaveParticipant(documents, mainThreadEditors);
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, mainThreadEditors);
let event: vscode.TextDocumentWillSaveEvent;
let sub = participant.onWillSaveTextDocumentEvent(function (e) {
let sub = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {
event = e;
});
@@ -77,9 +91,9 @@ suite('ExtHostDocumentSaveParticipant', () => {
});
test('event delivery, bad listener', () => {
const participant = new ExtHostDocumentSaveParticipant(documents, mainThreadEditors);
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, mainThreadEditors);
let sub = participant.onWillSaveTextDocumentEvent(function (e) {
let sub = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {
throw new Error('💀');
});
@@ -92,13 +106,13 @@ suite('ExtHostDocumentSaveParticipant', () => {
});
test('event delivery, bad listener doesn\'t prevent more events', () => {
const participant = new ExtHostDocumentSaveParticipant(documents, mainThreadEditors);
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, mainThreadEditors);
let sub1 = participant.onWillSaveTextDocumentEvent(function (e) {
let sub1 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {
throw new Error('💀');
});
let event: vscode.TextDocumentWillSaveEvent;
let sub2 = participant.onWillSaveTextDocumentEvent(function (e) {
let sub2 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {
event = e;
});
@@ -111,14 +125,14 @@ suite('ExtHostDocumentSaveParticipant', () => {
});
test('event delivery, in subscriber order', () => {
const participant = new ExtHostDocumentSaveParticipant(documents, mainThreadEditors);
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, mainThreadEditors);
let counter = 0;
let sub1 = participant.onWillSaveTextDocumentEvent(function (event) {
let sub1 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (event) {
assert.equal(counter++, 0);
});
let sub2 = participant.onWillSaveTextDocumentEvent(function (event) {
let sub2 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (event) {
assert.equal(counter++, 1);
});
@@ -128,42 +142,39 @@ suite('ExtHostDocumentSaveParticipant', () => {
});
});
test('event delivery, ignore bad listeners', () => {
const participant = new ExtHostDocumentSaveParticipant(documents, mainThreadEditors, { timeout: 5, errors: 1 });
test('event delivery, ignore bad listeners', async () => {
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, mainThreadEditors, { timeout: 5, errors: 1 });
let callCount = 0;
let sub = participant.onWillSaveTextDocumentEvent(function (event) {
let sub = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (event) {
callCount += 1;
throw new Error('boom');
});
return TPromise.join([
participant.$participateInSave(resource, SaveReason.EXPLICIT),
participant.$participateInSave(resource, SaveReason.EXPLICIT),
participant.$participateInSave(resource, SaveReason.EXPLICIT),
participant.$participateInSave(resource, SaveReason.EXPLICIT)
await participant.$participateInSave(resource, SaveReason.EXPLICIT);
await participant.$participateInSave(resource, SaveReason.EXPLICIT);
await participant.$participateInSave(resource, SaveReason.EXPLICIT);
await participant.$participateInSave(resource, SaveReason.EXPLICIT);
]).then(values => {
sub.dispose();
assert.equal(callCount, 2);
});
sub.dispose();
assert.equal(callCount, 2);
});
test('event delivery, overall timeout', () => {
const participant = new ExtHostDocumentSaveParticipant(documents, mainThreadEditors, { timeout: 20, errors: 5 });
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, mainThreadEditors, { timeout: 20, errors: 5 });
let callCount = 0;
let sub1 = participant.onWillSaveTextDocumentEvent(function (event) {
let sub1 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (event) {
callCount += 1;
event.waitUntil(TPromise.timeout(17));
});
let sub2 = participant.onWillSaveTextDocumentEvent(function (event) {
let sub2 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (event) {
callCount += 1;
event.waitUntil(TPromise.timeout(17));
});
let sub3 = participant.onWillSaveTextDocumentEvent(function (event) {
let sub3 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (event) {
callCount += 1;
});
@@ -178,9 +189,9 @@ suite('ExtHostDocumentSaveParticipant', () => {
});
test('event delivery, waitUntil', () => {
const participant = new ExtHostDocumentSaveParticipant(documents, mainThreadEditors);
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, mainThreadEditors);
let sub = participant.onWillSaveTextDocumentEvent(function (event) {
let sub = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (event) {
event.waitUntil(TPromise.timeout(10));
event.waitUntil(TPromise.timeout(10));
@@ -194,9 +205,9 @@ suite('ExtHostDocumentSaveParticipant', () => {
});
test('event delivery, waitUntil must be called sync', () => {
const participant = new ExtHostDocumentSaveParticipant(documents, mainThreadEditors);
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, mainThreadEditors);
let sub = participant.onWillSaveTextDocumentEvent(function (event) {
let sub = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (event) {
event.waitUntil(new TPromise((resolve, reject) => {
setTimeout(() => {
@@ -217,9 +228,9 @@ suite('ExtHostDocumentSaveParticipant', () => {
});
test('event delivery, waitUntil will timeout', () => {
const participant = new ExtHostDocumentSaveParticipant(documents, mainThreadEditors, { timeout: 5, errors: 3 });
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, mainThreadEditors, { timeout: 5, errors: 3 });
let sub = participant.onWillSaveTextDocumentEvent(function (event) {
let sub = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (event) {
event.waitUntil(TPromise.timeout(15));
});
@@ -232,14 +243,14 @@ suite('ExtHostDocumentSaveParticipant', () => {
});
test('event delivery, waitUntil failure handling', () => {
const participant = new ExtHostDocumentSaveParticipant(documents, mainThreadEditors);
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, mainThreadEditors);
let sub1 = participant.onWillSaveTextDocumentEvent(function (e) {
let sub1 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {
e.waitUntil(TPromise.wrapError(new Error('dddd')));
});
let event: vscode.TextDocumentWillSaveEvent;
let sub2 = participant.onWillSaveTextDocumentEvent(function (e) {
let sub2 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {
event = e;
});
@@ -252,15 +263,15 @@ suite('ExtHostDocumentSaveParticipant', () => {
test('event delivery, pushEdits sync', () => {
let edits: IWorkspaceResourceEdit[];
const participant = new ExtHostDocumentSaveParticipant(documents, new class extends mock<MainThreadEditorsShape>() {
$tryApplyWorkspaceEdit(_edits: IWorkspaceResourceEdit[]) {
edits = _edits;
let dto: WorkspaceEditDto;
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, new class extends mock<MainThreadTextEditorsShape>() {
$tryApplyWorkspaceEdit(_edits: WorkspaceEditDto) {
dto = _edits;
return TPromise.as(true);
}
});
let sub = participant.onWillSaveTextDocumentEvent(function (e) {
let sub = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {
e.waitUntil(TPromise.as([TextEdit.insert(new Position(0, 0), 'bar')]));
e.waitUntil(TPromise.as([TextEdit.setEndOfLine(EndOfLine.CRLF)]));
});
@@ -268,25 +279,26 @@ suite('ExtHostDocumentSaveParticipant', () => {
return participant.$participateInSave(resource, SaveReason.EXPLICIT).then(() => {
sub.dispose();
assert.equal(edits.length, 1);
assert.equal(edits[0].edits.length, 2);
assert.equal(dto.edits.length, 1);
assert.ok(isResourceTextEdit(dto.edits[0]));
assert.equal((<ResourceTextEdit>dto.edits[0]).edits.length, 2);
});
});
test('event delivery, concurrent change', () => {
let edits: IWorkspaceResourceEdit[];
const participant = new ExtHostDocumentSaveParticipant(documents, new class extends mock<MainThreadEditorsShape>() {
$tryApplyWorkspaceEdit(_edits: IWorkspaceResourceEdit[]) {
let edits: WorkspaceEditDto;
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, new class extends mock<MainThreadTextEditorsShape>() {
$tryApplyWorkspaceEdit(_edits: WorkspaceEditDto) {
edits = _edits;
return TPromise.as(true);
}
});
let sub = participant.onWillSaveTextDocumentEvent(function (e) {
let sub = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {
// concurrent change from somewhere
documents.$acceptModelChanged(resource.toString(), {
documents.$acceptModelChanged(resource, {
changes: [{
range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 },
rangeLength: undefined,
@@ -310,19 +322,24 @@ suite('ExtHostDocumentSaveParticipant', () => {
test('event delivery, two listeners -> two document states', () => {
const participant = new ExtHostDocumentSaveParticipant(documents, new class extends mock<MainThreadEditorsShape>() {
$tryApplyWorkspaceEdit(_edits: IWorkspaceResourceEdit[]) {
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, new class extends mock<MainThreadTextEditorsShape>() {
$tryApplyWorkspaceEdit(dto: WorkspaceEditDto) {
for (const { resource, edits } of _edits) {
for (const { newText, range } of edits) {
documents.$acceptModelChanged(resource.toString(), {
for (const edit of dto.edits) {
if (!isResourceTextEdit(edit)) {
continue;
}
const { resource, edits } = edit;
const uri = URI.revive(resource);
for (const { text, range } of edits) {
documents.$acceptModelChanged(uri, {
changes: [{
range,
text,
rangeLength: undefined,
text: newText
}],
eol: undefined,
versionId: documents.getDocumentData(resource).version + 1
versionId: documents.getDocumentData(uri).version + 1
}, true);
}
}
@@ -333,7 +350,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
const document = documents.getDocumentData(resource).document;
let sub1 = participant.onWillSaveTextDocumentEvent(function (e) {
let sub1 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {
// the document state we started with
assert.equal(document.version, 1);
assert.equal(document.getText(), 'foo');
@@ -341,7 +358,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
e.waitUntil(TPromise.as([TextEdit.insert(new Position(0, 0), 'bar')]));
});
let sub2 = participant.onWillSaveTextDocumentEvent(function (e) {
let sub2 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {
// the document state AFTER the first listener kicked in
assert.equal(document.version, 2);
assert.equal(document.getText(), 'barfoo');
@@ -359,4 +376,23 @@ suite('ExtHostDocumentSaveParticipant', () => {
});
});
test('Log failing listener', function () {
let didLogSomething = false;
let participant = new ExtHostDocumentSaveParticipant(new class extends NullLogService {
error(message: string | Error, ...args: any[]): void {
didLogSomething = true;
}
}, documents, mainThreadEditors);
let sub = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {
throw new Error('boom');
});
return participant.$participateInSave(resource, SaveReason.EXPLICIT).then(() => {
sub.dispose();
assert.equal(didLogSomething, true);
});
});
});