Merge from vscode bead496a613e475819f89f08e9e882b841bc1fe8 (#14883)

* Merge from vscode bead496a613e475819f89f08e9e882b841bc1fe8

* Bump distro

* Upgrade GCC to 4.9 due to yarn install errors

* Update build image

* Fix bootstrap base url

* Bump distro

* Fix build errors

* Update source map file

* Disable checkbox for blocking migration issues (#15131)

* disable checkbox for blocking issues

* wip

* disable checkbox fixes

* fix strings

* Remove duplicate tsec command

* Default to off for tab color if settings not present

* re-skip failing tests

* Fix mocha error

* Bump sqlite version & fix notebooks search view

* Turn off esbuild warnings

* Update esbuild log level

* Fix overflowactionbar tests

* Fix ts-ignore in dropdown tests

* cleanup/fixes

* Fix hygiene

* Bundle in entire zone.js module

* Remove extra constructor param

* bump distro for web compile break

* bump distro for web compile break v2

* Undo log level change

* New distro

* Fix integration test scripts

* remove the "no yarn.lock changes" workflow

* fix scripts v2

* Update unit test scripts

* Ensure ads-kerberos2 updates in .vscodeignore

* Try fix unit tests

* Upload crash reports

* remove nogpu

* always upload crashes

* Use bash script

* Consolidate data/ext dir names

* Create in tmp directory

Co-authored-by: chlafreniere <hichise@gmail.com>
Co-authored-by: Christopher Suh <chsuh@microsoft.com>
Co-authored-by: chgagnon <chgagnon@microsoft.com>
This commit is contained in:
Karl Burtram
2021-04-27 14:01:59 -07:00
committed by GitHub
parent 7e1c0076ba
commit 867a963882
1817 changed files with 81812 additions and 50843 deletions

View File

@@ -35,20 +35,21 @@ import { NullApiDeprecationService } from 'vs/workbench/api/common/extHostApiDep
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import { IResolvedTextEditorModel, ITextModelService } from 'vs/editor/common/services/resolverService';
import 'vs/editor/contrib/codeAction/codeAction';
import 'vs/editor/contrib/codelens/codelens';
import 'vs/editor/contrib/colorPicker/color';
import 'vs/editor/contrib/format/format';
import 'vs/editor/contrib/gotoSymbol/goToCommands';
import 'vs/editor/contrib/gotoSymbol/documentSymbols';
import 'vs/editor/contrib/documentSymbols/documentSymbols';
import 'vs/editor/contrib/hover/getHover';
import 'vs/editor/contrib/links/getLinks';
import 'vs/editor/contrib/parameterHints/provideSignatureHelp';
import 'vs/editor/contrib/smartSelect/smartSelect';
import 'vs/editor/contrib/suggest/suggest';
import 'vs/editor/contrib/rename/rename';
import { IResolvedTextEditorModel, ITextModelService } from 'vs/editor/common/services/resolverService';
import 'vs/editor/contrib/inlineHints/inlineHintsController';
const defaultSelector = { scheme: 'far' };
const model: ITextModel = createTextModel(
@@ -200,11 +201,11 @@ suite('ExtHostLanguageFeatureCommands', function () {
return commands.executeCommand<vscode.SymbolInformation[]>('vscode.executeWorkspaceSymbolProvider', 'testing').then(value => {
for (let info of value) {
assert.ok(info instanceof types.SymbolInformation);
assert.equal(info.name, 'testing');
assert.equal(info.kind, types.SymbolKind.Array);
assert.strictEqual(info instanceof types.SymbolInformation, true);
assert.strictEqual(info.name, 'testing');
assert.strictEqual(info.kind, types.SymbolKind.Array);
}
assert.equal(value.length, 3);
assert.strictEqual(value.length, 3);
});
});
});
@@ -219,11 +220,11 @@ suite('ExtHostLanguageFeatureCommands', function () {
await rpcProtocol.sync();
let symbols = await commands.executeCommand<vscode.SymbolInformation[]>('vscode.executeWorkspaceSymbolProvider', '');
assert.equal(symbols.length, 1);
assert.strictEqual(symbols.length, 1);
await rpcProtocol.sync();
symbols = await commands.executeCommand<vscode.SymbolInformation[]>('vscode.executeWorkspaceSymbolProvider', '*');
assert.equal(symbols.length, 1);
assert.strictEqual(symbols.length, 1);
});
// --- formatting
@@ -237,7 +238,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
await rpcProtocol.sync();
let edits = await commands.executeCommand<vscode.SymbolInformation[]>('vscode.executeFormatDocumentProvider', model.uri);
assert.equal(edits.length, 1);
assert.strictEqual(edits.length, 1);
});
@@ -256,10 +257,10 @@ suite('ExtHostLanguageFeatureCommands', function () {
const edit = await commands.executeCommand<vscode.WorkspaceEdit>('vscode.executeDocumentRenameProvider', model.uri, new types.Position(0, 12), 'newNameOfThis');
assert.ok(edit);
assert.equal(edit.has(model.uri), true);
assert.strictEqual(edit.has(model.uri), true);
const textEdits = edit.get(model.uri);
assert.equal(textEdits.length, 1);
assert.equal(textEdits[0].newText, 'newNameOfThis');
assert.strictEqual(textEdits.length, 1);
assert.strictEqual(textEdits[0].newText, 'newNameOfThis');
});
// --- definition
@@ -294,7 +295,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.Location[]>('vscode.executeDefinitionProvider', model.uri, new types.Position(0, 0)).then(values => {
assert.equal(values.length, 4);
assert.strictEqual(values.length, 4);
for (let v of values) {
assert.ok(v.uri instanceof URI);
assert.ok(v.range instanceof types.Range);
@@ -315,7 +316,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<(vscode.Location | vscode.LocationLink)[]>('vscode.executeDefinitionProvider', model.uri, new types.Position(0, 0)).then(values => {
assert.equal(values.length, 2);
assert.strictEqual(values.length, 2);
for (let v of values) {
if (isLocation(v)) {
assert.ok(v.uri instanceof URI);
@@ -352,7 +353,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.Location[]>('vscode.executeDeclarationProvider', model.uri, new types.Position(0, 0)).then(values => {
assert.equal(values.length, 4);
assert.strictEqual(values.length, 4);
for (let v of values) {
assert.ok(v.uri instanceof URI);
assert.ok(v.range instanceof types.Range);
@@ -373,7 +374,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<(vscode.Location | vscode.LocationLink)[]>('vscode.executeDeclarationProvider', model.uri, new types.Position(0, 0)).then(values => {
assert.equal(values.length, 2);
assert.strictEqual(values.length, 2);
for (let v of values) {
if (isLocation(v)) {
assert.ok(v.uri instanceof URI);
@@ -421,7 +422,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.Location[]>('vscode.executeTypeDefinitionProvider', model.uri, new types.Position(0, 0)).then(values => {
assert.equal(values.length, 4);
assert.strictEqual(values.length, 4);
for (const v of values) {
assert.ok(v.uri instanceof URI);
assert.ok(v.range instanceof types.Range);
@@ -442,7 +443,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<(vscode.Location | vscode.LocationLink)[]>('vscode.executeTypeDefinitionProvider', model.uri, new types.Position(0, 0)).then(values => {
assert.equal(values.length, 2);
assert.strictEqual(values.length, 2);
for (let v of values) {
if (isLocation(v)) {
assert.ok(v.uri instanceof URI);
@@ -490,7 +491,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.Location[]>('vscode.executeImplementationProvider', model.uri, new types.Position(0, 0)).then(values => {
assert.equal(values.length, 4);
assert.strictEqual(values.length, 4);
for (const v of values) {
assert.ok(v.uri instanceof URI);
assert.ok(v.range instanceof types.Range);
@@ -511,7 +512,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<(vscode.Location | vscode.LocationLink)[]>('vscode.executeImplementationProvider', model.uri, new types.Position(0, 0)).then(values => {
assert.equal(values.length, 2);
assert.strictEqual(values.length, 2);
for (let v of values) {
if (isLocation(v)) {
assert.ok(v.uri instanceof URI);
@@ -540,13 +541,13 @@ suite('ExtHostLanguageFeatureCommands', function () {
}));
return commands.executeCommand<vscode.Location[]>('vscode.executeReferenceProvider', model.uri, new types.Position(0, 0)).then(values => {
assert.equal(values.length, 1);
assert.strictEqual(values.length, 1);
let [first] = values;
assert.equal(first.uri.toString(), 'some:uri/path');
assert.equal(first.range.start.line, 0);
assert.equal(first.range.start.character, 1);
assert.equal(first.range.end.line, 0);
assert.equal(first.range.end.character, 5);
assert.strictEqual(first.uri.toString(), 'some:uri/path');
assert.strictEqual(first.range.start.line, 0);
assert.strictEqual(first.range.start.character, 1);
assert.strictEqual(first.range.end.line, 0);
assert.strictEqual(first.range.end.character, 5);
});
});
@@ -564,12 +565,12 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.SymbolInformation[]>('vscode.executeDocumentSymbolProvider', model.uri).then(values => {
assert.equal(values.length, 2);
assert.strictEqual(values.length, 2);
let [first, second] = values;
assert.ok(first instanceof types.SymbolInformation);
assert.ok(second instanceof types.SymbolInformation);
assert.equal(first.name, 'testing2');
assert.equal(second.name, 'testing1');
assert.strictEqual(first instanceof types.SymbolInformation, true);
assert.strictEqual(second instanceof types.SymbolInformation, true);
assert.strictEqual(first.name, 'testing2');
assert.strictEqual(second.name, 'testing1');
});
});
});
@@ -592,14 +593,14 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<(vscode.SymbolInformation & vscode.DocumentSymbol)[]>('vscode.executeDocumentSymbolProvider', model.uri).then(values => {
assert.equal(values.length, 2);
assert.strictEqual(values.length, 2);
let [first, second] = values;
assert.ok(first instanceof types.SymbolInformation);
assert.ok(!(first instanceof types.DocumentSymbol));
assert.ok(second instanceof types.SymbolInformation);
assert.equal(first.name, 'DocumentSymbol');
assert.equal(first.children.length, 1);
assert.equal(second.name, 'SymbolInformation');
assert.strictEqual(first instanceof types.SymbolInformation, true);
assert.strictEqual(first instanceof types.DocumentSymbol, false);
assert.strictEqual(second instanceof types.SymbolInformation, true);
assert.strictEqual(first.name, 'DocumentSymbol');
assert.strictEqual(first.children.length, 1);
assert.strictEqual(second.name, 'SymbolInformation');
});
});
});
@@ -629,37 +630,37 @@ suite('ExtHostLanguageFeatureCommands', function () {
assert.ok(list instanceof types.CompletionList);
let values = list.items;
assert.ok(Array.isArray(values));
assert.equal(values.length, 4);
assert.strictEqual(values.length, 4);
let [first, second, third, fourth] = values;
assert.equal(first.label, 'item1');
assert.equal(first.textEdit, undefined);// no text edit, default ranges
assert.strictEqual(first.label, 'item1');
assert.strictEqual(first.textEdit, undefined);// no text edit, default ranges
assert.ok(!types.Range.isRange(first.range));
assert.equal(second.label, 'item2');
assert.equal(second.textEdit!.newText, 'foo');
assert.equal(second.textEdit!.range.start.line, 0);
assert.equal(second.textEdit!.range.start.character, 4);
assert.equal(second.textEdit!.range.end.line, 0);
assert.equal(second.textEdit!.range.end.character, 8);
assert.strictEqual(second.label, 'item2');
assert.strictEqual(second.textEdit!.newText, 'foo');
assert.strictEqual(second.textEdit!.range.start.line, 0);
assert.strictEqual(second.textEdit!.range.start.character, 4);
assert.strictEqual(second.textEdit!.range.end.line, 0);
assert.strictEqual(second.textEdit!.range.end.character, 8);
assert.equal(third.label, 'item3');
assert.equal(third.textEdit!.newText, 'foobar');
assert.equal(third.textEdit!.range.start.line, 0);
assert.equal(third.textEdit!.range.start.character, 1);
assert.equal(third.textEdit!.range.end.line, 0);
assert.equal(third.textEdit!.range.end.character, 6);
assert.strictEqual(third.label, 'item3');
assert.strictEqual(third.textEdit!.newText, 'foobar');
assert.strictEqual(third.textEdit!.range.start.line, 0);
assert.strictEqual(third.textEdit!.range.start.character, 1);
assert.strictEqual(third.textEdit!.range.end.line, 0);
assert.strictEqual(third.textEdit!.range.end.character, 6);
assert.equal(fourth.label, 'item4');
assert.equal(fourth.textEdit, undefined);
assert.strictEqual(fourth.label, 'item4');
assert.strictEqual(fourth.textEdit, undefined);
const range: any = fourth.range!;
assert.ok(types.Range.isRange(range));
assert.equal(range.start.line, 0);
assert.equal(range.start.character, 1);
assert.equal(range.end.line, 0);
assert.equal(range.end.character, 4);
assert.strictEqual(range.start.line, 0);
assert.strictEqual(range.start.character, 1);
assert.strictEqual(range.end.line, 0);
assert.strictEqual(range.end.character, 4);
assert.ok(fourth.insertText instanceof types.SnippetString);
assert.equal((<types.SnippetString>fourth.insertText).value, 'foo$0bar');
assert.strictEqual((<types.SnippetString>fourth.insertText).value, 'foo$0bar');
});
});
});
@@ -676,7 +677,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.CompletionList>('vscode.executeCompletionItemProvider', model.uri, new types.Position(0, 4)).then(list => {
assert.ok(list instanceof types.CompletionList);
assert.equal(list.isIncomplete, true);
assert.strictEqual(list.isIncomplete, true);
});
});
});
@@ -710,7 +711,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
);
assert.ok(list instanceof types.CompletionList);
assert.equal(resolveCount, 2);
assert.strictEqual(resolveCount, 2);
});
@@ -737,13 +738,13 @@ suite('ExtHostLanguageFeatureCommands', function () {
);
assert.ok(list instanceof types.CompletionList);
assert.equal(list.items.length, 4);
assert.strictEqual(list.items.length, 4);
let [a, b, c, d] = list.items;
assert.equal(a.preselect, true);
assert.equal(b.preselect, undefined);
assert.equal(c.preselect, true);
assert.equal(d.preselect, undefined);
assert.strictEqual(a.preselect, true);
assert.strictEqual(b.preselect, undefined);
assert.strictEqual(c.preselect, true);
assert.strictEqual(d.preselect, undefined);
});
test('executeCompletionItemProvider doesn\'t capture commitCharacters #58228', async function () {
@@ -766,11 +767,11 @@ suite('ExtHostLanguageFeatureCommands', function () {
);
assert.ok(list instanceof types.CompletionList);
assert.equal(list.items.length, 2);
assert.strictEqual(list.items.length, 2);
let [a, b] = list.items;
assert.deepEqual(a.commitCharacters, ['a', 'b']);
assert.equal(b.commitCharacters, undefined);
assert.deepStrictEqual(a.commitCharacters, ['a', 'b']);
assert.strictEqual(b.commitCharacters, undefined);
});
test('vscode.executeCompletionItemProvider returns the wrong CompletionItemKinds in insiders #95715', async function () {
@@ -793,11 +794,11 @@ suite('ExtHostLanguageFeatureCommands', function () {
);
assert.ok(list instanceof types.CompletionList);
assert.equal(list.items.length, 2);
assert.strictEqual(list.items.length, 2);
const [a, b] = list.items;
assert.equal(a.kind, types.CompletionItemKind.Method);
assert.equal(b.kind, types.CompletionItemKind.Property);
assert.strictEqual(a.kind, types.CompletionItemKind.Method);
assert.strictEqual(b.kind, types.CompletionItemKind.Property);
});
// --- signatureHelp
@@ -840,11 +841,11 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.Command[]>('vscode.executeCodeActionProvider', model.uri, new types.Range(0, 0, 1, 1)).then(value => {
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
let [first] = value;
assert.equal(first.title, 'Title');
assert.equal(first.command, 'testing');
assert.deepEqual(first.arguments, [1, 2, true]);
assert.strictEqual(first.title, 'Title');
assert.strictEqual(first.command, 'testing');
assert.deepStrictEqual(first.arguments, [1, 2, true]);
});
});
});
@@ -866,13 +867,13 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.CodeAction[]>('vscode.executeCodeActionProvider', model.uri, new types.Range(0, 0, 1, 1)).then(value => {
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
const [first] = value;
assert.ok(first.command);
assert.equal(first.command!.command, 'command');
assert.equal(first.command!.title, 'command_title');
assert.equal(first.kind!.value, 'foo');
assert.equal(first.title, 'title');
assert.strictEqual(first.command!.command, 'command');
assert.strictEqual(first.command!.title, 'command_title');
assert.strictEqual(first.kind!.value, 'foo');
assert.strictEqual(first.title, 'title');
});
});
@@ -897,7 +898,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.CodeAction[]>('vscode.executeCodeActionProvider', model.uri, selection).then(value => {
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
const [first] = value;
assert.ok(first.command);
assert.ok(first.command!.arguments![1] instanceof types.Selection);
@@ -926,9 +927,9 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.CodeAction[]>('vscode.executeCodeActionProvider', model.uri, selection).then(value => {
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
const [first] = value;
assert.equal(first.isPreferred, true);
assert.strictEqual(first.isPreferred, true);
});
});
});
@@ -957,11 +958,11 @@ suite('ExtHostLanguageFeatureCommands', function () {
await rpcProtocol.sync();
const value = await commands.executeCommand<vscode.CodeAction[]>('vscode.executeCodeActionProvider', model.uri, selection, undefined, 1000);
assert.equal(didCallResolve, 1);
assert.equal(value.length, 1);
assert.strictEqual(didCallResolve, 1);
assert.strictEqual(value.length, 1);
const [first] = value;
assert.equal(first.title, 'title'); // does NOT change
assert.strictEqual(first.title, 'title'); // does NOT change
assert.ok(first.edit); // is set
});
@@ -983,14 +984,14 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.CodeLens[]>('vscode.executeCodeLensProvider', model.uri).then(value => {
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
const [first] = value;
assert.equal(first.command!.title, 'Title');
assert.equal(first.command!.command, 'cmd');
assert.equal(first.command!.arguments![0], 1);
assert.equal(first.command!.arguments![1], true);
assert.equal(first.command!.arguments![2], complexArg);
assert.strictEqual(first.command!.title, 'Title');
assert.strictEqual(first.command!.command, 'cmd');
assert.strictEqual(first.command!.arguments![0], 1);
assert.strictEqual(first.command!.arguments![1], true);
assert.strictEqual(first.command!.arguments![2], complexArg);
});
});
});
@@ -1019,14 +1020,14 @@ suite('ExtHostLanguageFeatureCommands', function () {
let value = await commands.executeCommand<vscode.CodeLens[]>('vscode.executeCodeLensProvider', model.uri, 2);
assert.equal(value.length, 3); // the resolve argument defines the number of results being returned
assert.equal(resolveCount, 2);
assert.strictEqual(value.length, 3); // the resolve argument defines the number of results being returned
assert.strictEqual(resolveCount, 2);
resolveCount = 0;
value = await commands.executeCommand<vscode.CodeLens[]>('vscode.executeCodeLensProvider', model.uri);
assert.equal(value.length, 4);
assert.equal(resolveCount, 0);
assert.strictEqual(value.length, 4);
assert.strictEqual(resolveCount, 0);
});
test('Links, back and forth', function () {
@@ -1039,14 +1040,14 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.DocumentLink[]>('vscode.executeLinkProvider', model.uri).then(value => {
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
let [first] = value;
assert.equal(first.target + '', 'foo:bar');
assert.equal(first.range.start.line, 0);
assert.equal(first.range.start.character, 0);
assert.equal(first.range.end.line, 0);
assert.equal(first.range.end.character, 20);
assert.strictEqual(first.target + '', 'foo:bar');
assert.strictEqual(first.range.start.line, 0);
assert.strictEqual(first.range.start.character, 0);
assert.strictEqual(first.range.end.line, 0);
assert.strictEqual(first.range.end.character, 20);
});
});
});
@@ -1065,12 +1066,12 @@ suite('ExtHostLanguageFeatureCommands', function () {
await rpcProtocol.sync();
const links1 = await commands.executeCommand<vscode.DocumentLink[]>('vscode.executeLinkProvider', model.uri);
assert.equal(links1.length, 1);
assert.equal(links1[0].target, undefined);
assert.strictEqual(links1.length, 1);
assert.strictEqual(links1[0].target, undefined);
const links2 = await commands.executeCommand<vscode.DocumentLink[]>('vscode.executeLinkProvider', model.uri, 1000);
assert.equal(links2.length, 1);
assert.equal(links2[0].target!.toString(), URI.parse('foo:bar').toString());
assert.strictEqual(links2.length, 1);
assert.strictEqual(links2[0].target!.toString(), URI.parse('foo:bar').toString());
});
@@ -1091,36 +1092,36 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.ColorInformation[]>('vscode.executeDocumentColorProvider', model.uri).then(value => {
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
let [first] = value;
assert.equal(first.color.red, 0.1);
assert.equal(first.color.green, 0.2);
assert.equal(first.color.blue, 0.3);
assert.equal(first.color.alpha, 0.4);
assert.equal(first.range.start.line, 0);
assert.equal(first.range.start.character, 0);
assert.equal(first.range.end.line, 0);
assert.equal(first.range.end.character, 20);
assert.strictEqual(first.color.red, 0.1);
assert.strictEqual(first.color.green, 0.2);
assert.strictEqual(first.color.blue, 0.3);
assert.strictEqual(first.color.alpha, 0.4);
assert.strictEqual(first.range.start.line, 0);
assert.strictEqual(first.range.start.character, 0);
assert.strictEqual(first.range.end.line, 0);
assert.strictEqual(first.range.end.character, 20);
});
}).then(() => {
const color = new types.Color(0.5, 0.6, 0.7, 0.8);
const range = new types.Range(0, 0, 0, 20);
return commands.executeCommand<vscode.ColorPresentation[]>('vscode.executeColorPresentationProvider', color, { uri: model.uri, range }).then(value => {
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
let [first] = value;
assert.equal(first.label, '#ABC');
assert.equal(first.textEdit!.newText, '#ABC');
assert.equal(first.textEdit!.range.start.line, 1);
assert.equal(first.textEdit!.range.start.character, 0);
assert.equal(first.textEdit!.range.end.line, 1);
assert.equal(first.textEdit!.range.end.character, 20);
assert.equal(first.additionalTextEdits!.length, 1);
assert.equal(first.additionalTextEdits![0].range.start.line, 2);
assert.equal(first.additionalTextEdits![0].range.start.character, 20);
assert.equal(first.additionalTextEdits![0].range.end.line, 2);
assert.equal(first.additionalTextEdits![0].range.end.character, 20);
assert.strictEqual(first.label, '#ABC');
assert.strictEqual(first.textEdit!.newText, '#ABC');
assert.strictEqual(first.textEdit!.range.start.line, 1);
assert.strictEqual(first.textEdit!.range.start.character, 0);
assert.strictEqual(first.textEdit!.range.end.line, 1);
assert.strictEqual(first.textEdit!.range.end.character, 20);
assert.strictEqual(first.additionalTextEdits!.length, 1);
assert.strictEqual(first.additionalTextEdits![0].range.start.line, 2);
assert.strictEqual(first.additionalTextEdits![0].range.start.character, 20);
assert.strictEqual(first.additionalTextEdits![0].range.end.line, 2);
assert.strictEqual(first.additionalTextEdits![0].range.end.character, 20);
});
});
});
@@ -1135,12 +1136,93 @@ suite('ExtHostLanguageFeatureCommands', function () {
return rpcProtocol.sync().then(() => {
return commands.executeCommand<vscode.Hover[]>('vscode.executeHoverProvider', model.uri, new types.Position(1, 1)).then(value => {
assert.equal(value.length, 1);
assert.equal(value[0].contents.length, 1);
assert.strictEqual(value.length, 1);
assert.strictEqual(value[0].contents.length, 1);
});
});
});
// --- inline hints
test('Inline Hints, back and forth', async function () {
disposables.push(extHost.registerInlineHintsProvider(nullExtensionDescription, defaultSelector, <vscode.InlineHintsProvider>{
provideInlineHints() {
return [new types.InlineHint('Foo', new types.Range(0, 1, 2, 3), undefined, true, false)];
}
}));
await rpcProtocol.sync();
const value = await commands.executeCommand<vscode.InlineHint[]>('vscode.executeInlineHintProvider', model.uri, new types.Range(0, 0, 20, 20));
assert.strictEqual(value.length, 1);
const [first] = value;
assert.strictEqual(first.text, 'Foo');
assert.strictEqual(first.range.start.line, 0);
assert.strictEqual(first.range.start.character, 1);
assert.strictEqual(first.range.end.line, 2);
assert.strictEqual(first.range.end.character, 3);
});
test('Inline Hints, merge', async function () {
disposables.push(extHost.registerInlineHintsProvider(nullExtensionDescription, defaultSelector, <vscode.InlineHintsProvider>{
provideInlineHints() {
return [new types.InlineHint('Bar', new types.Range(10, 11, 12, 13), undefined, true, false)];
}
}));
disposables.push(extHost.registerInlineHintsProvider(nullExtensionDescription, defaultSelector, <vscode.InlineHintsProvider>{
provideInlineHints() {
return [new types.InlineHint('Foo', new types.Range(0, 1, 2, 3), new types.MarkdownString('**Hello**'), true, false)];
}
}));
await rpcProtocol.sync();
const value = await commands.executeCommand<vscode.InlineHint[]>('vscode.executeInlineHintProvider', model.uri, new types.Range(0, 0, 20, 20));
assert.strictEqual(value.length, 2);
const [first, second] = value;
assert.strictEqual(first.text, 'Foo');
assert.strictEqual(first.range.start.line, 0);
assert.strictEqual(first.range.start.character, 1);
assert.strictEqual(first.range.end.line, 2);
assert.strictEqual(first.range.end.character, 3);
assert.ok(first.description instanceof types.MarkdownString);
assert.strictEqual((<types.MarkdownString>first.description).value, '**Hello**');
assert.strictEqual(second.text, 'Bar');
assert.strictEqual(second.range.start.line, 10);
assert.strictEqual(second.range.start.character, 11);
assert.strictEqual(second.range.end.line, 12);
assert.strictEqual(second.range.end.character, 13);
});
test('Inline Hints, bad provider', async function () {
disposables.push(extHost.registerInlineHintsProvider(nullExtensionDescription, defaultSelector, <vscode.InlineHintsProvider>{
provideInlineHints() {
return [new types.InlineHint('Foo', new types.Range(0, 1, 2, 3), undefined, true, false)];
}
}));
disposables.push(extHost.registerInlineHintsProvider(nullExtensionDescription, defaultSelector, <vscode.InlineHintsProvider>{
provideInlineHints() {
throw new Error();
}
}));
await rpcProtocol.sync();
const value = await commands.executeCommand<vscode.InlineHint[]>('vscode.executeInlineHintProvider', model.uri, new types.Range(0, 0, 20, 20));
assert.strictEqual(value.length, 1);
const [first] = value;
assert.strictEqual(first.text, 'Foo');
assert.strictEqual(first.range.start.line, 0);
assert.strictEqual(first.range.start.character, 1);
assert.strictEqual(first.range.end.line, 2);
assert.strictEqual(first.range.end.character, 3);
});
// --- selection ranges
test('Selection Range, back and forth', async function () {
@@ -1155,7 +1237,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
await rpcProtocol.sync();
let value = await commands.executeCommand<vscode.SelectionRange[]>('vscode.executeSelectionRangeProvider', model.uri, [new types.Position(0, 10)]);
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
assert.ok(value[0].parent);
});
@@ -1190,16 +1272,16 @@ suite('ExtHostLanguageFeatureCommands', function () {
const root = await commands.executeCommand<vscode.CallHierarchyItem[]>('vscode.prepareCallHierarchy', model.uri, new types.Position(0, 0));
assert.ok(Array.isArray(root));
assert.equal(root.length, 1);
assert.equal(root[0].name, 'ROOT');
assert.strictEqual(root.length, 1);
assert.strictEqual(root[0].name, 'ROOT');
const incoming = await commands.executeCommand<vscode.CallHierarchyIncomingCall[]>('vscode.provideIncomingCalls', root[0]);
assert.equal(incoming.length, 1);
assert.equal(incoming[0].from.name, 'INCOMING');
assert.strictEqual(incoming.length, 1);
assert.strictEqual(incoming[0].from.name, 'INCOMING');
const outgoing = await commands.executeCommand<vscode.CallHierarchyOutgoingCall[]>('vscode.provideOutgoingCalls', root[0]);
assert.equal(outgoing.length, 1);
assert.equal(outgoing[0].to.name, 'OUTGOING');
assert.strictEqual(outgoing.length, 1);
assert.strictEqual(outgoing[0].to.name, 'OUTGOING');
});
test('selectionRangeProvider on inner array always returns outer array #91852', async function () {
@@ -1215,11 +1297,11 @@ suite('ExtHostLanguageFeatureCommands', function () {
await rpcProtocol.sync();
let value = await commands.executeCommand<vscode.SelectionRange[]>('vscode.executeSelectionRangeProvider', model.uri, [new types.Position(0, 10)]);
assert.equal(value.length, 1);
assert.equal(value[0].range.start.line, 0);
assert.equal(value[0].range.start.character, 10);
assert.equal(value[0].range.end.line, 0);
assert.equal(value[0].range.end.character, 10);
assert.strictEqual(value.length, 1);
assert.strictEqual(value[0].range.start.line, 0);
assert.strictEqual(value[0].range.start.character, 10);
assert.strictEqual(value[0].range.end.line, 0);
assert.strictEqual(value[0].range.end.character, 10);
});
test('selectionRangeProvider on inner array always returns outer array #91852', async function () {
@@ -1240,14 +1322,14 @@ suite('ExtHostLanguageFeatureCommands', function () {
model.uri,
[new types.Position(0, 0), new types.Position(0, 10)]
);
assert.equal(value.length, 2);
assert.equal(value[0].range.start.line, 0);
assert.equal(value[0].range.start.character, 0);
assert.equal(value[0].range.end.line, 0);
assert.equal(value[0].range.end.character, 0);
assert.equal(value[1].range.start.line, 0);
assert.equal(value[1].range.start.character, 10);
assert.equal(value[1].range.end.line, 0);
assert.equal(value[1].range.end.character, 10);
assert.strictEqual(value.length, 2);
assert.strictEqual(value[0].range.start.line, 0);
assert.strictEqual(value[0].range.start.character, 0);
assert.strictEqual(value[0].range.end.line, 0);
assert.strictEqual(value[0].range.end.character, 0);
assert.strictEqual(value[1].range.start.line, 0);
assert.strictEqual(value[1].range.start.character, 10);
assert.strictEqual(value[1].range.end.line, 0);
assert.strictEqual(value[1].range.end.character, 10);
});
});

View File

@@ -47,17 +47,17 @@ suite('ExtHostBulkEdits.applyWorkspaceEdit', () => {
let edit = new extHostTypes.WorkspaceEdit();
edit.replace(resource, new extHostTypes.Range(0, 0, 0, 0), 'hello');
await bulkEdits.applyWorkspaceEdit(edit);
assert.equal(workspaceResourceEdits.edits.length, 1);
assert.strictEqual(workspaceResourceEdits.edits.length, 1);
const [first] = workspaceResourceEdits.edits;
assertType(first._type === WorkspaceEditType.Text);
assert.equal(first.modelVersionId, 1337);
assert.strictEqual(first.modelVersionId, 1337);
});
test('does not use version id if document is not available', async () => {
let edit = new extHostTypes.WorkspaceEdit();
edit.replace(URI.parse('foo:bar2'), new extHostTypes.Range(0, 0, 0, 0), 'hello');
await bulkEdits.applyWorkspaceEdit(edit);
assert.equal(workspaceResourceEdits.edits.length, 1);
assert.strictEqual(workspaceResourceEdits.edits.length, 1);
const [first] = workspaceResourceEdits.edits;
assertType(first._type === WorkspaceEditType.Text);
assert.ok(typeof first.modelVersionId === 'undefined');

View File

@@ -31,8 +31,8 @@ suite('ExtHostCommands', function () {
new NullLogService()
);
commands.registerCommand(true, 'foo', (): any => { }).dispose();
assert.equal(lastUnregister!, 'foo');
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
assert.strictEqual(lastUnregister!, 'foo');
assert.strictEqual(CommandsRegistry.getCommand('foo'), undefined);
});
@@ -57,7 +57,7 @@ suite('ExtHostCommands', function () {
reg.dispose();
reg.dispose();
reg.dispose();
assert.equal(unregisterCounter, 1);
assert.strictEqual(unregisterCounter, 1);
});
test('execute with retry', async function () {
@@ -70,12 +70,12 @@ suite('ExtHostCommands', function () {
}
async $executeCommand<T>(id: string, args: any[], retry: boolean): Promise<T | undefined> {
count++;
assert.equal(retry, count === 1);
assert.strictEqual(retry, count === 1);
if (count === 1) {
assert.equal(retry, true);
assert.strictEqual(retry, true);
throw new Error('$executeCommand:retry');
} else {
assert.equal(retry, false);
assert.strictEqual(retry, false);
return <any>17;
}
}
@@ -87,7 +87,7 @@ suite('ExtHostCommands', function () {
);
const result = await commands.executeCommand('fooo', [this, true]);
assert.equal(result, 17);
assert.equal(count, 2);
assert.strictEqual(result, 17);
assert.strictEqual(count, 2);
});
});

View File

@@ -59,12 +59,12 @@ suite('ExtHostConfiguration', function () {
}
});
assert.equal(extHostConfig.getConfiguration('search.exclude')['**/node_modules'], true);
assert.equal(extHostConfig.getConfiguration('search.exclude').get('**/node_modules'), true);
assert.equal(extHostConfig.getConfiguration('search').get<any>('exclude')['**/node_modules'], true);
assert.strictEqual(extHostConfig.getConfiguration('search.exclude')['**/node_modules'], true);
assert.strictEqual(extHostConfig.getConfiguration('search.exclude').get('**/node_modules'), true);
assert.strictEqual(extHostConfig.getConfiguration('search').get<any>('exclude')['**/node_modules'], true);
assert.equal(extHostConfig.getConfiguration('search.exclude').has('**/node_modules'), true);
assert.equal(extHostConfig.getConfiguration('search').has('exclude.**/node_modules'), true);
assert.strictEqual(extHostConfig.getConfiguration('search.exclude').has('**/node_modules'), true);
assert.strictEqual(extHostConfig.getConfiguration('search').has('exclude.**/node_modules'), true);
});
test('has/get', () => {
@@ -83,18 +83,18 @@ suite('ExtHostConfiguration', function () {
const config = all.getConfiguration('farboo');
assert.ok(config.has('config0'));
assert.equal(config.get('config0'), true);
assert.equal(config.get('config4'), '');
assert.equal(config['config0'], true);
assert.equal(config['config4'], '');
assert.strictEqual(config.get('config0'), true);
assert.strictEqual(config.get('config4'), '');
assert.strictEqual(config['config0'], true);
assert.strictEqual(config['config4'], '');
assert.ok(config.has('nested.config1'));
assert.equal(config.get('nested.config1'), 42);
assert.strictEqual(config.get('nested.config1'), 42);
assert.ok(config.has('nested.config2'));
assert.equal(config.get('nested.config2'), 'Das Pferd frisst kein Reis.');
assert.strictEqual(config.get('nested.config2'), 'Das Pferd frisst kein Reis.');
assert.ok(config.has('nested'));
assert.deepEqual(config.get('nested'), { config1: 42, config2: 'Das Pferd frisst kein Reis.' });
assert.deepStrictEqual(config.get('nested'), { config1: 42, config2: 'Das Pferd frisst kein Reis.' });
});
test('can modify the returned configuration', function () {
@@ -118,37 +118,37 @@ suite('ExtHostConfiguration', function () {
let testObject = all.getConfiguration();
let actual = testObject.get<any>('farboo')!;
actual['nested']['config1'] = 41;
assert.equal(41, actual['nested']['config1']);
assert.strictEqual(41, actual['nested']['config1']);
actual['farboo1'] = 'newValue';
assert.equal('newValue', actual['farboo1']);
assert.strictEqual('newValue', actual['farboo1']);
testObject = all.getConfiguration();
actual = testObject.get('farboo')!;
assert.equal(actual['nested']['config1'], 42);
assert.equal(actual['farboo1'], undefined);
assert.strictEqual(actual['nested']['config1'], 42);
assert.strictEqual(actual['farboo1'], undefined);
testObject = all.getConfiguration();
actual = testObject.get('farboo')!;
assert.equal(actual['config0'], true);
assert.strictEqual(actual['config0'], true);
actual['config0'] = false;
assert.equal(actual['config0'], false);
assert.strictEqual(actual['config0'], false);
testObject = all.getConfiguration();
actual = testObject.get('farboo')!;
assert.equal(actual['config0'], true);
assert.strictEqual(actual['config0'], true);
testObject = all.getConfiguration();
actual = testObject.inspect('farboo')!;
actual['value'] = 'effectiveValue';
assert.equal('effectiveValue', actual['value']);
assert.strictEqual('effectiveValue', actual['value']);
testObject = all.getConfiguration('workbench');
actual = testObject.get('colorCustomizations')!;
actual['statusBar.foreground'] = undefined;
assert.equal(actual['statusBar.foreground'], undefined);
assert.strictEqual(actual['statusBar.foreground'], undefined);
testObject = all.getConfiguration('workbench');
actual = testObject.get('colorCustomizations')!;
assert.equal(actual['statusBar.foreground'], 'somevalue');
assert.strictEqual(actual['statusBar.foreground'], 'somevalue');
});
test('Stringify returned configuration', function () {
@@ -173,7 +173,7 @@ suite('ExtHostConfiguration', function () {
const testObject = all.getConfiguration();
let actual: any = testObject.get('farboo');
assert.deepEqual(JSON.stringify({
assert.deepStrictEqual(JSON.stringify({
'config0': true,
'nested': {
'config1': 42,
@@ -182,11 +182,11 @@ suite('ExtHostConfiguration', function () {
'config4': ''
}), JSON.stringify(actual));
assert.deepEqual(undefined, JSON.stringify(testObject.get('unknownkey')));
assert.deepStrictEqual(undefined, JSON.stringify(testObject.get('unknownkey')));
actual = testObject.get('farboo')!;
actual['config0'] = false;
assert.deepEqual(JSON.stringify({
assert.deepStrictEqual(JSON.stringify({
'config0': false,
'nested': {
'config1': 42,
@@ -197,14 +197,14 @@ suite('ExtHostConfiguration', function () {
actual = testObject.get<any>('workbench')!['colorCustomizations']!;
actual['statusBar.background'] = 'anothervalue';
assert.deepEqual(JSON.stringify({
assert.deepStrictEqual(JSON.stringify({
'statusBar.foreground': 'somevalue',
'statusBar.background': 'anothervalue'
}), JSON.stringify(actual));
actual = testObject.get('workbench');
actual['unknownkey'] = 'somevalue';
assert.deepEqual(JSON.stringify({
assert.deepStrictEqual(JSON.stringify({
'colorCustomizations': {
'statusBar.foreground': 'somevalue'
},
@@ -218,7 +218,7 @@ suite('ExtHostConfiguration', function () {
'statusBar.background': `#0ff`,
'statusBar.foreground': `#ff0`,
};
assert.deepEqual(JSON.stringify({
assert.deepStrictEqual(JSON.stringify({
'statusBar.background': `#0ff`,
'statusBar.foreground': `#ff0`,
}), JSON.stringify(actual));
@@ -229,7 +229,7 @@ suite('ExtHostConfiguration', function () {
'statusBar.background': `#0ff`,
'statusBar.foreground': `#ff0`,
};
assert.deepEqual(JSON.stringify({
assert.deepStrictEqual(JSON.stringify({
'statusBar.background': `#0ff`,
'statusBar.foreground': `#ff0`,
}), JSON.stringify(actual));
@@ -292,16 +292,16 @@ suite('ExtHostConfiguration', function () {
);
let actual = testObject.getConfiguration().inspect('editor.wordWrap')!;
assert.equal(actual.defaultValue, 'off');
assert.equal(actual.globalValue, 'on');
assert.equal(actual.workspaceValue, undefined);
assert.equal(actual.workspaceFolderValue, undefined);
assert.strictEqual(actual.defaultValue, 'off');
assert.strictEqual(actual.globalValue, 'on');
assert.strictEqual(actual.workspaceValue, undefined);
assert.strictEqual(actual.workspaceFolderValue, undefined);
actual = testObject.getConfiguration('editor').inspect('wordWrap')!;
assert.equal(actual.defaultValue, 'off');
assert.equal(actual.globalValue, 'on');
assert.equal(actual.workspaceValue, undefined);
assert.equal(actual.workspaceFolderValue, undefined);
assert.strictEqual(actual.defaultValue, 'off');
assert.strictEqual(actual.globalValue, 'on');
assert.strictEqual(actual.workspaceValue, undefined);
assert.strictEqual(actual.workspaceFolderValue, undefined);
});
test('inspect in single root context', function () {
@@ -341,28 +341,28 @@ suite('ExtHostConfiguration', function () {
);
let actual1 = testObject.getConfiguration().inspect('editor.wordWrap')!;
assert.equal(actual1.defaultValue, 'off');
assert.equal(actual1.globalValue, 'on');
assert.equal(actual1.workspaceValue, 'bounded');
assert.equal(actual1.workspaceFolderValue, undefined);
assert.strictEqual(actual1.defaultValue, 'off');
assert.strictEqual(actual1.globalValue, 'on');
assert.strictEqual(actual1.workspaceValue, 'bounded');
assert.strictEqual(actual1.workspaceFolderValue, undefined);
actual1 = testObject.getConfiguration('editor').inspect('wordWrap')!;
assert.equal(actual1.defaultValue, 'off');
assert.equal(actual1.globalValue, 'on');
assert.equal(actual1.workspaceValue, 'bounded');
assert.equal(actual1.workspaceFolderValue, undefined);
assert.strictEqual(actual1.defaultValue, 'off');
assert.strictEqual(actual1.globalValue, 'on');
assert.strictEqual(actual1.workspaceValue, 'bounded');
assert.strictEqual(actual1.workspaceFolderValue, undefined);
let actual2 = testObject.getConfiguration(undefined, workspaceUri).inspect('editor.wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.equal(actual2.workspaceFolderValue, 'bounded');
assert.strictEqual(actual2.defaultValue, 'off');
assert.strictEqual(actual2.globalValue, 'on');
assert.strictEqual(actual2.workspaceValue, 'bounded');
assert.strictEqual(actual2.workspaceFolderValue, 'bounded');
actual2 = testObject.getConfiguration('editor', workspaceUri).inspect('wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.equal(actual2.workspaceFolderValue, 'bounded');
assert.strictEqual(actual2.defaultValue, 'off');
assert.strictEqual(actual2.globalValue, 'on');
assert.strictEqual(actual2.workspaceValue, 'bounded');
assert.strictEqual(actual2.workspaceFolderValue, 'bounded');
});
test('inspect in multi root context', function () {
@@ -418,66 +418,66 @@ suite('ExtHostConfiguration', function () {
);
let actual1 = testObject.getConfiguration().inspect('editor.wordWrap')!;
assert.equal(actual1.defaultValue, 'off');
assert.equal(actual1.globalValue, 'on');
assert.equal(actual1.workspaceValue, 'bounded');
assert.equal(actual1.workspaceFolderValue, undefined);
assert.strictEqual(actual1.defaultValue, 'off');
assert.strictEqual(actual1.globalValue, 'on');
assert.strictEqual(actual1.workspaceValue, 'bounded');
assert.strictEqual(actual1.workspaceFolderValue, undefined);
actual1 = testObject.getConfiguration('editor').inspect('wordWrap')!;
assert.equal(actual1.defaultValue, 'off');
assert.equal(actual1.globalValue, 'on');
assert.equal(actual1.workspaceValue, 'bounded');
assert.equal(actual1.workspaceFolderValue, undefined);
assert.strictEqual(actual1.defaultValue, 'off');
assert.strictEqual(actual1.globalValue, 'on');
assert.strictEqual(actual1.workspaceValue, 'bounded');
assert.strictEqual(actual1.workspaceFolderValue, undefined);
actual1 = testObject.getConfiguration('editor').inspect('lineNumbers')!;
assert.equal(actual1.defaultValue, 'on');
assert.equal(actual1.globalValue, undefined);
assert.equal(actual1.workspaceValue, undefined);
assert.equal(actual1.workspaceFolderValue, undefined);
assert.strictEqual(actual1.defaultValue, 'on');
assert.strictEqual(actual1.globalValue, undefined);
assert.strictEqual(actual1.workspaceValue, undefined);
assert.strictEqual(actual1.workspaceFolderValue, undefined);
let actual2 = testObject.getConfiguration(undefined, firstRoot).inspect('editor.wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.equal(actual2.workspaceFolderValue, 'off');
assert.strictEqual(actual2.defaultValue, 'off');
assert.strictEqual(actual2.globalValue, 'on');
assert.strictEqual(actual2.workspaceValue, 'bounded');
assert.strictEqual(actual2.workspaceFolderValue, 'off');
actual2 = testObject.getConfiguration('editor', firstRoot).inspect('wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.equal(actual2.workspaceFolderValue, 'off');
assert.strictEqual(actual2.defaultValue, 'off');
assert.strictEqual(actual2.globalValue, 'on');
assert.strictEqual(actual2.workspaceValue, 'bounded');
assert.strictEqual(actual2.workspaceFolderValue, 'off');
actual2 = testObject.getConfiguration('editor', firstRoot).inspect('lineNumbers')!;
assert.equal(actual2.defaultValue, 'on');
assert.equal(actual2.globalValue, undefined);
assert.equal(actual2.workspaceValue, undefined);
assert.equal(actual2.workspaceFolderValue, 'relative');
assert.strictEqual(actual2.defaultValue, 'on');
assert.strictEqual(actual2.globalValue, undefined);
assert.strictEqual(actual2.workspaceValue, undefined);
assert.strictEqual(actual2.workspaceFolderValue, 'relative');
actual2 = testObject.getConfiguration(undefined, secondRoot).inspect('editor.wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.equal(actual2.workspaceFolderValue, 'on');
assert.strictEqual(actual2.defaultValue, 'off');
assert.strictEqual(actual2.globalValue, 'on');
assert.strictEqual(actual2.workspaceValue, 'bounded');
assert.strictEqual(actual2.workspaceFolderValue, 'on');
actual2 = testObject.getConfiguration('editor', secondRoot).inspect('wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.equal(actual2.workspaceFolderValue, 'on');
assert.strictEqual(actual2.defaultValue, 'off');
assert.strictEqual(actual2.globalValue, 'on');
assert.strictEqual(actual2.workspaceValue, 'bounded');
assert.strictEqual(actual2.workspaceFolderValue, 'on');
actual2 = testObject.getConfiguration(undefined, thirdRoot).inspect('editor.wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.strictEqual(actual2.defaultValue, 'off');
assert.strictEqual(actual2.globalValue, 'on');
assert.strictEqual(actual2.workspaceValue, 'bounded');
assert.ok(Object.keys(actual2).indexOf('workspaceFolderValue') !== -1);
assert.equal(actual2.workspaceFolderValue, undefined);
assert.strictEqual(actual2.workspaceFolderValue, undefined);
actual2 = testObject.getConfiguration('editor', thirdRoot).inspect('wordWrap')!;
assert.equal(actual2.defaultValue, 'off');
assert.equal(actual2.globalValue, 'on');
assert.equal(actual2.workspaceValue, 'bounded');
assert.strictEqual(actual2.defaultValue, 'off');
assert.strictEqual(actual2.globalValue, 'on');
assert.strictEqual(actual2.workspaceValue, 'bounded');
assert.ok(Object.keys(actual2).indexOf('workspaceFolderValue') !== -1);
assert.equal(actual2.workspaceFolderValue, undefined);
assert.strictEqual(actual2.workspaceFolderValue, undefined);
});
test('inspect with language overrides', function () {
@@ -527,26 +527,26 @@ suite('ExtHostConfiguration', function () {
);
let actual = testObject.getConfiguration(undefined, { uri: firstRoot, languageId: 'typescript' }).inspect('editor.wordWrap')!;
assert.equal(actual.defaultValue, 'off');
assert.equal(actual.globalValue, 'bounded');
assert.equal(actual.workspaceValue, undefined);
assert.equal(actual.workspaceFolderValue, 'bounded');
assert.equal(actual.defaultLanguageValue, undefined);
assert.equal(actual.globalLanguageValue, undefined);
assert.equal(actual.workspaceLanguageValue, 'unbounded');
assert.equal(actual.workspaceFolderLanguageValue, 'unbounded');
assert.deepEqual(actual.languageIds, ['markdown', 'typescript']);
assert.strictEqual(actual.defaultValue, 'off');
assert.strictEqual(actual.globalValue, 'bounded');
assert.strictEqual(actual.workspaceValue, undefined);
assert.strictEqual(actual.workspaceFolderValue, 'bounded');
assert.strictEqual(actual.defaultLanguageValue, undefined);
assert.strictEqual(actual.globalLanguageValue, undefined);
assert.strictEqual(actual.workspaceLanguageValue, 'unbounded');
assert.strictEqual(actual.workspaceFolderLanguageValue, 'unbounded');
assert.deepStrictEqual(actual.languageIds, ['markdown', 'typescript']);
actual = testObject.getConfiguration(undefined, { uri: secondRoot, languageId: 'typescript' }).inspect('editor.wordWrap')!;
assert.equal(actual.defaultValue, 'off');
assert.equal(actual.globalValue, 'bounded');
assert.equal(actual.workspaceValue, undefined);
assert.equal(actual.workspaceFolderValue, undefined);
assert.equal(actual.defaultLanguageValue, undefined);
assert.equal(actual.globalLanguageValue, undefined);
assert.equal(actual.workspaceLanguageValue, 'unbounded');
assert.equal(actual.workspaceFolderLanguageValue, undefined);
assert.deepEqual(actual.languageIds, ['markdown', 'typescript']);
assert.strictEqual(actual.defaultValue, 'off');
assert.strictEqual(actual.globalValue, 'bounded');
assert.strictEqual(actual.workspaceValue, undefined);
assert.strictEqual(actual.workspaceFolderValue, undefined);
assert.strictEqual(actual.defaultLanguageValue, undefined);
assert.strictEqual(actual.globalLanguageValue, undefined);
assert.strictEqual(actual.workspaceLanguageValue, 'unbounded');
assert.strictEqual(actual.workspaceFolderLanguageValue, undefined);
assert.deepStrictEqual(actual.languageIds, ['markdown', 'typescript']);
});
@@ -560,12 +560,12 @@ suite('ExtHostConfiguration', function () {
});
let config = all.getConfiguration('farboo.config0');
assert.equal(config.get(''), undefined);
assert.equal(config.has(''), false);
assert.strictEqual(config.get(''), undefined);
assert.strictEqual(config.has(''), false);
config = all.getConfiguration('farboo');
assert.equal(config.get('config0'), true);
assert.equal(config.has('config0'), true);
assert.strictEqual(config.get('config0'), true);
assert.strictEqual(config.has('config0'), true);
});
test('getConfiguration vs get', function () {
@@ -578,12 +578,12 @@ suite('ExtHostConfiguration', function () {
});
let config = all.getConfiguration('farboo.config0');
assert.equal(config.get(''), undefined);
assert.equal(config.has(''), false);
assert.strictEqual(config.get(''), undefined);
assert.strictEqual(config.has(''), false);
config = all.getConfiguration('farboo');
assert.equal(config.get('config0'), true);
assert.equal(config.has('config0'), true);
assert.strictEqual(config.get('config0'), true);
assert.strictEqual(config.has('config0'), true);
});
test('name vs property', function () {
@@ -595,8 +595,8 @@ suite('ExtHostConfiguration', function () {
const config = all.getConfiguration('farboo');
assert.ok(config.has('get'));
assert.equal(config.get('get'), 'get-prop');
assert.deepEqual(config['get'], config.get);
assert.strictEqual(config.get('get'), 'get-prop');
assert.deepStrictEqual(config['get'], config.get);
assert.throws(() => config['get'] = <any>'get-prop');
});
@@ -612,7 +612,7 @@ suite('ExtHostConfiguration', function () {
let config = allConfig.getConfiguration('foo');
config.update('bar', 42);
assert.equal(shape.lastArgs[0], null);
assert.strictEqual(shape.lastArgs[0], null);
});
test('update/section to key', function () {
@@ -628,16 +628,16 @@ suite('ExtHostConfiguration', function () {
let config = allConfig.getConfiguration('foo');
config.update('bar', 42, true);
assert.equal(shape.lastArgs[0], ConfigurationTarget.USER);
assert.equal(shape.lastArgs[1], 'foo.bar');
assert.equal(shape.lastArgs[2], 42);
assert.strictEqual(shape.lastArgs[0], ConfigurationTarget.USER);
assert.strictEqual(shape.lastArgs[1], 'foo.bar');
assert.strictEqual(shape.lastArgs[2], 42);
config = allConfig.getConfiguration('');
config.update('bar', 42, true);
assert.equal(shape.lastArgs[1], 'bar');
assert.strictEqual(shape.lastArgs[1], 'bar');
config.update('foo.bar', 42, true);
assert.equal(shape.lastArgs[1], 'foo.bar');
assert.strictEqual(shape.lastArgs[1], 'foo.bar');
});
test('update, what is #15834', function () {
@@ -649,8 +649,8 @@ suite('ExtHostConfiguration', function () {
}, shape);
allConfig.getConfiguration('editor').update('formatOnSave', { extensions: ['ts'] });
assert.equal(shape.lastArgs[1], 'editor.formatOnSave');
assert.deepEqual(shape.lastArgs[2], { extensions: ['ts'] });
assert.strictEqual(shape.lastArgs[1], 'editor.formatOnSave');
assert.deepStrictEqual(shape.lastArgs[2], { extensions: ['ts'] });
});
test('update/error-state not OK', function () {
@@ -698,7 +698,7 @@ suite('ExtHostConfiguration', function () {
const configEventData: IConfigurationChange = { keys: ['farboo.updatedConfig', 'farboo.newConfig'], overrides: [] };
testObject.onDidChangeConfiguration(e => {
assert.deepEqual(testObject.getConfiguration().get('farboo'), {
assert.deepStrictEqual(testObject.getConfiguration().get('farboo'), {
'config': false,
'updatedConfig': true,
'newConfig': true,

View File

@@ -68,17 +68,17 @@ suite('ExtHostDecorations', function () {
return extHostDecorations.$provideDecorations(handle, [{ id: idx, uri: URI.parse('test:///file') }], CancellationToken.None);
});
assert.equal(calledA, true);
assert.equal(calledB, true);
assert.strictEqual(calledA, true);
assert.strictEqual(calledB, true);
assert.equal(requests.length, 2);
assert.strictEqual(requests.length, 2);
const [first, second] = requests;
const firstResult = await Promise.race([first, timeout(30).then(() => false)]);
assert.equal(typeof firstResult, 'boolean'); // never finishes...
assert.strictEqual(typeof firstResult, 'boolean'); // never finishes...
const secondResult = await Promise.race([second, timeout(30).then(() => false)]);
assert.equal(typeof secondResult, 'object');
assert.strictEqual(typeof secondResult, 'object');
});
});

View File

@@ -45,26 +45,26 @@ suite('ExtHostDiagnostics', () => {
test('diagnostic collection, forEach, clear, has', function () {
let collection = new DiagnosticCollection('test', 'test', 100, new DiagnosticsShape(), new Emitter());
assert.equal(collection.name, 'test');
assert.strictEqual(collection.name, 'test');
collection.dispose();
assert.throws(() => collection.name);
let c = 0;
collection = new DiagnosticCollection('test', 'test', 100, new DiagnosticsShape(), new Emitter());
collection.forEach(() => c++);
assert.equal(c, 0);
assert.strictEqual(c, 0);
collection.set(URI.parse('foo:bar'), [
new Diagnostic(new Range(0, 0, 1, 1), 'message-1'),
new Diagnostic(new Range(0, 0, 1, 1), 'message-2')
]);
collection.forEach(() => c++);
assert.equal(c, 1);
assert.strictEqual(c, 1);
c = 0;
collection.clear();
collection.forEach(() => c++);
assert.equal(c, 0);
assert.strictEqual(c, 0);
collection.set(URI.parse('foo:bar1'), [
new Diagnostic(new Range(0, 0, 1, 1), 'message-1'),
@@ -75,7 +75,7 @@ suite('ExtHostDiagnostics', () => {
new Diagnostic(new Range(0, 0, 1, 1), 'message-2')
]);
collection.forEach(() => c++);
assert.equal(c, 2);
assert.strictEqual(c, 2);
assert.ok(collection.has(URI.parse('foo:bar1')));
assert.ok(collection.has(URI.parse('foo:bar2')));
@@ -105,7 +105,7 @@ suite('ExtHostDiagnostics', () => {
});
array = collection.get(URI.parse('foo:bar')) as Diagnostic[];
assert.equal(array.length, 2);
assert.strictEqual(array.length, 2);
collection.dispose();
});
@@ -121,10 +121,10 @@ suite('ExtHostDiagnostics', () => {
]);
let array = collection.get(uri);
assert.equal(array.length, 2);
assert.strictEqual(array.length, 2);
let [first, second] = array;
assert.equal(first.message, 'message-1');
assert.equal(second.message, 'message-2');
assert.strictEqual(first.message, 'message-1');
assert.strictEqual(second.message, 'message-2');
// clear
collection.delete(uri);
@@ -152,10 +152,10 @@ suite('ExtHostDiagnostics', () => {
]);
array = collection.get(uri);
assert.equal(array.length, 2);
assert.strictEqual(array.length, 2);
[first, second] = array;
assert.equal(first.message, 'message-2');
assert.equal(second.message, 'message-3');
assert.strictEqual(first.message, 'message-2');
assert.strictEqual(second.message, 'message-3');
collection.dispose();
});
@@ -172,21 +172,21 @@ suite('ExtHostDiagnostics', () => {
let uri = URI.parse('sc:hightower');
collection.set([[uri, [new Diagnostic(new Range(0, 0, 1, 1), 'error')]]]);
assert.equal(collection.get(uri).length, 1);
assert.equal(collection.get(uri)[0].message, 'error');
assert.equal(lastEntries.length, 1);
assert.strictEqual(collection.get(uri).length, 1);
assert.strictEqual(collection.get(uri)[0].message, 'error');
assert.strictEqual(lastEntries.length, 1);
let [[, data1]] = lastEntries;
assert.equal(data1.length, 1);
assert.equal(data1[0].message, 'error');
assert.strictEqual(data1.length, 1);
assert.strictEqual(data1[0].message, 'error');
lastEntries = undefined!;
collection.set([[uri, [new Diagnostic(new Range(0, 0, 1, 1), 'warning')]]]);
assert.equal(collection.get(uri).length, 1);
assert.equal(collection.get(uri)[0].message, 'warning');
assert.equal(lastEntries.length, 1);
assert.strictEqual(collection.get(uri).length, 1);
assert.strictEqual(collection.get(uri)[0].message, 'warning');
assert.strictEqual(lastEntries.length, 1);
let [[, data2]] = lastEntries;
assert.equal(data2.length, 1);
assert.equal(data2[0].message, 'warning');
assert.strictEqual(data2.length, 1);
assert.strictEqual(data2[0].message, 'warning');
lastEntries = undefined!;
});
@@ -207,12 +207,12 @@ suite('ExtHostDiagnostics', () => {
let diag = new Diagnostic(new Range(0, 0, 0, 1), 'ffff');
collection.set(uri, [diag]);
assert.equal(changeCount, 1);
assert.equal(eventCount, 1);
assert.strictEqual(changeCount, 1);
assert.strictEqual(eventCount, 1);
collection.set(uri, [diag]);
assert.equal(changeCount, 2);
assert.equal(eventCount, 2);
assert.strictEqual(changeCount, 2);
assert.strictEqual(eventCount, 2);
});
test('diagnostics collection, tuples and undefined (small array), #15585', function () {
@@ -232,8 +232,8 @@ suite('ExtHostDiagnostics', () => {
[uri2, [diag]],
]);
assert.equal(collection.get(uri).length, 1);
assert.equal(collection.get(uri2).length, 1);
assert.strictEqual(collection.get(uri).length, 1);
assert.strictEqual(collection.get(uri2).length, 1);
});
test('diagnostics collection, tuples and undefined (large array), #15585', function () {
@@ -254,8 +254,8 @@ suite('ExtHostDiagnostics', () => {
for (let i = 0; i < 500; i++) {
let uri = URI.parse('sc:hightower#' + i);
assert.equal(collection.has(uri), true);
assert.equal(collection.get(uri).length, 1);
assert.strictEqual(collection.has(uri), true);
assert.strictEqual(collection.get(uri).length, 1);
}
});
@@ -278,12 +278,12 @@ suite('ExtHostDiagnostics', () => {
}
collection.set(uri, diagnostics);
assert.equal(collection.get(uri).length, 500);
assert.equal(lastEntries.length, 1);
assert.equal(lastEntries[0][1].length, 251);
assert.equal(lastEntries[0][1][0].severity, MarkerSeverity.Error);
assert.equal(lastEntries[0][1][200].severity, MarkerSeverity.Warning);
assert.equal(lastEntries[0][1][250].severity, MarkerSeverity.Info);
assert.strictEqual(collection.get(uri).length, 500);
assert.strictEqual(lastEntries.length, 1);
assert.strictEqual(lastEntries[0][1].length, 251);
assert.strictEqual(lastEntries[0][1][0].severity, MarkerSeverity.Error);
assert.strictEqual(lastEntries[0][1][200].severity, MarkerSeverity.Warning);
assert.strictEqual(lastEntries[0][1][250].severity, MarkerSeverity.Info);
});
test('diagnostic eventing', async function () {
@@ -295,19 +295,19 @@ suite('ExtHostDiagnostics', () => {
let diag3 = new Diagnostic(new Range(1, 1, 2, 3), 'diag3');
let p = Event.toPromise(emitter.event).then(a => {
assert.equal(a.length, 1);
assert.equal(a[0].toString(), 'aa:bb');
assert.strictEqual(a.length, 1);
assert.strictEqual(a[0].toString(), 'aa:bb');
assert.ok(URI.isUri(a[0]));
});
collection.set(URI.parse('aa:bb'), []);
await p;
p = Event.toPromise(emitter.event).then(e => {
assert.equal(e.length, 2);
assert.strictEqual(e.length, 2);
assert.ok(URI.isUri(e[0]));
assert.ok(URI.isUri(e[1]));
assert.equal(e[0].toString(), 'aa:bb');
assert.equal(e[1].toString(), 'aa:cc');
assert.strictEqual(e[0].toString(), 'aa:bb');
assert.strictEqual(e[1].toString(), 'aa:cc');
});
collection.set([
[URI.parse('aa:bb'), [diag1]],
@@ -316,7 +316,7 @@ suite('ExtHostDiagnostics', () => {
await p;
p = Event.toPromise(emitter.event).then(e => {
assert.equal(e.length, 2);
assert.strictEqual(e.length, 2);
assert.ok(URI.isUri(e[0]));
assert.ok(URI.isUri(e[1]));
});
@@ -333,7 +333,7 @@ suite('ExtHostDiagnostics', () => {
// delete
collection.set(URI.parse('aa:bb'), [diag1]);
let p = Event.toPromise(emitter.event).then(e => {
assert.equal(e[0].toString(), 'aa:bb');
assert.strictEqual(e[0].toString(), 'aa:bb');
});
collection.delete(URI.parse('aa:bb'));
await p;
@@ -341,7 +341,7 @@ suite('ExtHostDiagnostics', () => {
// set->undefined (as delete)
collection.set(URI.parse('aa:bb'), [diag1]);
p = Event.toPromise(emitter.event).then(e => {
assert.equal(e[0].toString(), 'aa:bb');
assert.strictEqual(e[0].toString(), 'aa:bb');
});
collection.set(URI.parse('aa:bb'), undefined!);
await p;
@@ -353,13 +353,13 @@ suite('ExtHostDiagnostics', () => {
$changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]) {
let [[, data]] = entries;
assert.equal(entries.length, 1);
assert.equal(data.length, 1);
assert.strictEqual(entries.length, 1);
assert.strictEqual(data.length, 1);
let [diag] = data;
assert.equal(diag.relatedInformation!.length, 2);
assert.equal(diag.relatedInformation![0].message, 'more1');
assert.equal(diag.relatedInformation![1].message, 'more2');
assert.strictEqual(diag.relatedInformation!.length, 2);
assert.strictEqual(diag.relatedInformation![0].message, 'more1');
assert.strictEqual(diag.relatedInformation![1].message, 'more2');
done();
}
}, new Emitter<any>());
@@ -400,9 +400,9 @@ suite('ExtHostDiagnostics', () => {
collection1.clear();
collection2.clear();
assert.equal(ownerHistory.length, 2);
assert.equal(ownerHistory[0], 'foo');
assert.equal(ownerHistory[1], 'foo0');
assert.strictEqual(ownerHistory.length, 2);
assert.strictEqual(ownerHistory[0], 'foo');
assert.strictEqual(ownerHistory[1], 'foo0');
});
test('Error updating diagnostics from extension #60394', function () {
@@ -420,14 +420,14 @@ suite('ExtHostDiagnostics', () => {
array.push(diag1, diag2);
collection.set(URI.parse('test:me'), array);
assert.equal(callCount, 1);
assert.strictEqual(callCount, 1);
collection.set(URI.parse('test:me'), array);
assert.equal(callCount, 2); // equal array
assert.strictEqual(callCount, 2); // equal array
array.push(diag2);
collection.set(URI.parse('test:me'), array);
assert.equal(callCount, 3); // same but un-equal array
assert.strictEqual(callCount, 3); // same but un-equal array
});
test('Diagnostics created by tasks aren\'t accessible to extensions #47292', async function () {
@@ -461,11 +461,11 @@ suite('ExtHostDiagnostics', () => {
const p1 = Event.toPromise(diags.onDidChangeDiagnostics);
diags.$acceptMarkersChange([[uri, data]]);
await p1;
assert.equal(diags.getDiagnostics(uri).length, 1);
assert.strictEqual(diags.getDiagnostics(uri).length, 1);
const p2 = Event.toPromise(diags.onDidChangeDiagnostics);
diags.$acceptMarkersChange([[uri, []]]);
await p2;
assert.equal(diags.getDiagnostics(uri).length, 0);
assert.strictEqual(diags.getDiagnostics(uri).length, 0);
});
});

View File

@@ -19,14 +19,14 @@ suite('ExtHostDocumentData', () => {
function assertPositionAt(offset: number, line: number, character: number) {
let position = data.document.positionAt(offset);
assert.equal(position.line, line);
assert.equal(position.character, character);
assert.strictEqual(position.line, line);
assert.strictEqual(position.character, character);
}
function assertOffsetAt(line: number, character: number, offset: number) {
let pos = new Position(line, character);
let actual = data.document.offsetAt(pos);
assert.equal(actual, offset);
assert.strictEqual(actual, offset);
}
setup(function () {
@@ -58,7 +58,7 @@ suite('ExtHostDocumentData', () => {
}, URI.parse('foo:bar'), [], '\n', 1, 'text', true);
return data.document.save().then(() => {
assert.equal(saved.toString(), 'foo:bar');
assert.strictEqual(saved.toString(), 'foo:bar');
data.dispose();
@@ -74,13 +74,13 @@ suite('ExtHostDocumentData', () => {
data.dispose();
const { document } = data;
assert.equal(document.lineCount, 4);
assert.equal(document.lineAt(0).text, 'This is line one');
assert.strictEqual(document.lineCount, 4);
assert.strictEqual(document.lineAt(0).text, 'This is line one');
});
test('lines', () => {
assert.equal(data.document.lineCount, 4);
assert.strictEqual(data.document.lineCount, 4);
assert.throws(() => data.document.lineAt(-1));
assert.throws(() => data.document.lineAt(data.document.lineCount));
@@ -89,11 +89,11 @@ suite('ExtHostDocumentData', () => {
assert.throws(() => data.document.lineAt(0.8));
let line = data.document.lineAt(0);
assert.equal(line.lineNumber, 0);
assert.equal(line.text.length, 16);
assert.equal(line.text, 'This is line one');
assert.equal(line.isEmptyOrWhitespace, false);
assert.equal(line.firstNonWhitespaceCharacterIndex, 0);
assert.strictEqual(line.lineNumber, 0);
assert.strictEqual(line.text.length, 16);
assert.strictEqual(line.text, 'This is line one');
assert.strictEqual(line.isEmptyOrWhitespace, false);
assert.strictEqual(line.firstNonWhitespaceCharacterIndex, 0);
data.onEvents({
changes: [{
@@ -107,31 +107,31 @@ suite('ExtHostDocumentData', () => {
});
// line didn't change
assert.equal(line.text, 'This is line one');
assert.equal(line.firstNonWhitespaceCharacterIndex, 0);
assert.strictEqual(line.text, 'This is line one');
assert.strictEqual(line.firstNonWhitespaceCharacterIndex, 0);
// fetch line again
line = data.document.lineAt(0);
assert.equal(line.text, '\t This is line one');
assert.equal(line.firstNonWhitespaceCharacterIndex, 2);
assert.strictEqual(line.text, '\t This is line one');
assert.strictEqual(line.firstNonWhitespaceCharacterIndex, 2);
});
test('line, issue #5704', function () {
let line = data.document.lineAt(0);
let { range, rangeIncludingLineBreak } = line;
assert.equal(range.end.line, 0);
assert.equal(range.end.character, 16);
assert.equal(rangeIncludingLineBreak.end.line, 1);
assert.equal(rangeIncludingLineBreak.end.character, 0);
assert.strictEqual(range.end.line, 0);
assert.strictEqual(range.end.character, 16);
assert.strictEqual(rangeIncludingLineBreak.end.line, 1);
assert.strictEqual(rangeIncludingLineBreak.end.character, 0);
line = data.document.lineAt(data.document.lineCount - 1);
range = line.range;
rangeIncludingLineBreak = line.rangeIncludingLineBreak;
assert.equal(range.end.line, 3);
assert.equal(range.end.character, 29);
assert.equal(rangeIncludingLineBreak.end.line, 3);
assert.equal(rangeIncludingLineBreak.end.character, 29);
assert.strictEqual(range.end.line, 3);
assert.strictEqual(range.end.character, 29);
assert.strictEqual(rangeIncludingLineBreak.end.line, 3);
assert.strictEqual(rangeIncludingLineBreak.end.character, 29);
});
@@ -245,28 +245,28 @@ suite('ExtHostDocumentData', () => {
], '\n', 1, 'text', false);
let range = data.document.getWordRangeAtPosition(new Position(0, 2))!;
assert.equal(range.start.line, 0);
assert.equal(range.start.character, 0);
assert.equal(range.end.line, 0);
assert.equal(range.end.character, 4);
assert.strictEqual(range.start.line, 0);
assert.strictEqual(range.start.character, 0);
assert.strictEqual(range.end.line, 0);
assert.strictEqual(range.end.character, 4);
// ignore bad regular expresson /.*/
assert.throws(() => data.document.getWordRangeAtPosition(new Position(0, 2), /.*/)!);
range = data.document.getWordRangeAtPosition(new Position(0, 5), /[a-z+]+/)!;
assert.equal(range.start.line, 0);
assert.equal(range.start.character, 5);
assert.equal(range.end.line, 0);
assert.equal(range.end.character, 14);
assert.strictEqual(range.start.line, 0);
assert.strictEqual(range.start.character, 5);
assert.strictEqual(range.end.line, 0);
assert.strictEqual(range.end.character, 14);
range = data.document.getWordRangeAtPosition(new Position(0, 17), /[a-z+]+/)!;
assert.equal(range.start.line, 0);
assert.equal(range.start.character, 15);
assert.equal(range.end.line, 0);
assert.equal(range.end.character, 18);
assert.strictEqual(range.start.line, 0);
assert.strictEqual(range.start.character, 15);
assert.strictEqual(range.end.line, 0);
assert.strictEqual(range.end.character, 18);
range = data.document.getWordRangeAtPosition(new Position(0, 11), /yy/)!;
assert.equal(range, undefined);
assert.strictEqual(range, undefined);
});
test('getWordRangeAtPosition doesn\'t quite use the regex as expected, #29102', function () {
@@ -279,22 +279,22 @@ suite('ExtHostDocumentData', () => {
], '\n', 1, 'text', false);
let range = data.document.getWordRangeAtPosition(new Position(0, 0), /\/\*.+\*\//);
assert.equal(range, undefined);
assert.strictEqual(range, undefined);
range = data.document.getWordRangeAtPosition(new Position(1, 0), /\/\*.+\*\//)!;
assert.equal(range.start.line, 1);
assert.equal(range.start.character, 0);
assert.equal(range.end.line, 1);
assert.equal(range.end.character, 14);
assert.strictEqual(range.start.line, 1);
assert.strictEqual(range.start.character, 0);
assert.strictEqual(range.end.line, 1);
assert.strictEqual(range.end.character, 14);
range = data.document.getWordRangeAtPosition(new Position(3, 0), /("|').*\1/);
assert.equal(range, undefined);
assert.strictEqual(range, undefined);
range = data.document.getWordRangeAtPosition(new Position(3, 1), /("|').*\1/)!;
assert.equal(range.start.line, 3);
assert.equal(range.start.character, 1);
assert.equal(range.end.line, 3);
assert.equal(range.end.character, 10);
assert.strictEqual(range.start.line, 3);
assert.strictEqual(range.start.character, 1);
assert.strictEqual(range.end.line, 3);
assert.strictEqual(range.end.character, 10);
});
@@ -307,13 +307,13 @@ suite('ExtHostDocumentData', () => {
], '\n', 1, 'text', false);
let range = data.document.getWordRangeAtPosition(new Position(0, 1_177_170), regex)!;
assert.equal(range, undefined);
assert.strictEqual(range, undefined);
const pos = new Position(0, 1177170);
range = data.document.getWordRangeAtPosition(pos)!;
assert.ok(range);
assert.ok(range.contains(pos));
assert.equal(data.document.getText(range), 'TaskDefinition');
assert.strictEqual(data.document.getText(range), 'TaskDefinition');
});
test('Rename popup sometimes populates with text on the left side omitted #96013', function () {
@@ -326,10 +326,10 @@ suite('ExtHostDocumentData', () => {
], '\n', 1, 'text', false);
let range = data.document.getWordRangeAtPosition(new Position(0, 27), regex)!;
assert.equal(range.start.line, 0);
assert.equal(range.end.line, 0);
assert.equal(range.start.character, 4);
assert.equal(range.end.character, 28);
assert.strictEqual(range.start.line, 0);
assert.strictEqual(range.end.line, 0);
assert.strictEqual(range.start.character, 4);
assert.strictEqual(range.end.character, 28);
});
test('Custom snippet $TM_SELECTED_TEXT not show suggestion #108892', function () {
@@ -340,11 +340,11 @@ suite('ExtHostDocumentData', () => {
const pos = new Position(0, 55);
const range = data.document.getWordRangeAtPosition(pos)!;
assert.equal(range.start.line, 0);
assert.equal(range.end.line, 0);
assert.equal(range.start.character, 47);
assert.equal(range.end.character, 61);
assert.equal(data.document.getText(range), 'soprannominato');
assert.strictEqual(range.start.line, 0);
assert.strictEqual(range.end.line, 0);
assert.strictEqual(range.start.character, 47);
assert.strictEqual(range.end.character, 61);
assert.strictEqual(data.document.getText(range), 'soprannominato');
});
});
@@ -365,7 +365,7 @@ suite('ExtHostDocumentData updates line mapping', () => {
let line = 0, character = 0, previousIsCarriageReturn = false;
for (let offset = 0; offset <= allText.length; offset++) {
// The position coordinate system cannot express the position between \r and \n
let position = new Position(line, character + (previousIsCarriageReturn ? -1 : 0));
const position = new Position(line, character + (previousIsCarriageReturn ? -1 : 0));
if (direction === AssertDocumentLineMappingDirection.OffsetToPosition) {
let actualPosition = doc.document.positionAt(offset);

View File

@@ -68,8 +68,8 @@ suite('ExtHostDocumentSaveParticipant', () => {
sub.dispose();
assert.ok(event);
assert.equal(event.reason, TextDocumentSaveReason.Manual);
assert.equal(typeof event.waitUntil, 'function');
assert.strictEqual(event.reason, TextDocumentSaveReason.Manual);
assert.strictEqual(typeof event.waitUntil, 'function');
});
});
@@ -100,7 +100,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
sub.dispose();
const [first] = values;
assert.equal(first, false);
assert.strictEqual(first, false);
});
});
@@ -128,11 +128,11 @@ suite('ExtHostDocumentSaveParticipant', () => {
let counter = 0;
let sub1 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (event) {
assert.equal(counter++, 0);
assert.strictEqual(counter++, 0);
});
let sub2 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (event) {
assert.equal(counter++, 1);
assert.strictEqual(counter++, 1);
});
return participant.$participateInSave(resource, SaveReason.EXPLICIT).then(() => {
@@ -156,7 +156,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
await participant.$participateInSave(resource, SaveReason.EXPLICIT);
sub.dispose();
assert.equal(callCount, 2);
assert.strictEqual(callCount, 2);
});
test('event delivery, overall timeout', () => {
@@ -182,8 +182,8 @@ suite('ExtHostDocumentSaveParticipant', () => {
sub2.dispose();
sub3.dispose();
assert.equal(callCount, 2);
assert.equal(values.length, 2);
assert.strictEqual(callCount, 2);
assert.strictEqual(values.length, 2);
});
});
@@ -226,18 +226,19 @@ suite('ExtHostDocumentSaveParticipant', () => {
});
});
test('event delivery, waitUntil will timeout', () => {
test('event delivery, waitUntil will timeout', function () {
const participant = new ExtHostDocumentSaveParticipant(nullLogService, documents, mainThreadBulkEdits, { timeout: 5, errors: 3 });
let sub = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (event) {
event.waitUntil(timeout(15));
event.waitUntil(timeout(100));
});
return participant.$participateInSave(resource, SaveReason.EXPLICIT).then(values => {
sub.dispose();
const [first] = values;
assert.equal(first, false);
assert.strictEqual(first, false);
});
});
@@ -278,7 +279,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
return participant.$participateInSave(resource, SaveReason.EXPLICIT).then(() => {
sub.dispose();
assert.equal(dto.edits.length, 2);
assert.strictEqual(dto.edits.length, 2);
assert.ok((<IWorkspaceTextEditDto>dto.edits[0]).edit);
assert.ok((<IWorkspaceTextEditDto>dto.edits[1]).edit);
});
@@ -314,8 +315,8 @@ suite('ExtHostDocumentSaveParticipant', () => {
return participant.$participateInSave(resource, SaveReason.EXPLICIT).then(values => {
sub.dispose();
assert.equal(edits, undefined);
assert.equal(values[0], false);
assert.strictEqual(edits, undefined);
assert.strictEqual(values[0], false);
});
});
@@ -350,16 +351,16 @@ suite('ExtHostDocumentSaveParticipant', () => {
let sub1 = participant.getOnWillSaveTextDocumentEvent(nullExtensionDescription)(function (e) {
// the document state we started with
assert.equal(document.version, 1);
assert.equal(document.getText(), 'foo');
assert.strictEqual(document.version, 1);
assert.strictEqual(document.getText(), 'foo');
e.waitUntil(Promise.resolve([TextEdit.insert(new Position(0, 0), 'bar')]));
});
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');
assert.strictEqual(document.version, 2);
assert.strictEqual(document.getText(), 'barfoo');
e.waitUntil(Promise.resolve([TextEdit.insert(new Position(0, 0), 'bar')]));
});
@@ -369,8 +370,8 @@ suite('ExtHostDocumentSaveParticipant', () => {
sub2.dispose();
// the document state AFTER eventing is done
assert.equal(document.version, 3);
assert.equal(document.getText(), 'barbarfoo');
assert.strictEqual(document.version, 3);
assert.strictEqual(document.getText(), 'barbarfoo');
});
});
@@ -390,7 +391,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
return participant.$participateInSave(resource, SaveReason.EXPLICIT).then(() => {
sub.dispose();
assert.equal(didLogSomething, true);
assert.strictEqual(didLogSomething, true);
});
});
});

View File

@@ -39,7 +39,7 @@ suite('ExtHostDocumentsAndEditors', () => {
try {
for (const data of e) {
assert.equal(data.document.isClosed, true);
assert.strictEqual(data.document.isClosed, true);
}
resolve(undefined);
} catch (e) {

View File

@@ -20,14 +20,14 @@ suite('ExtHostFileSystemEventService', () => {
};
const watcher1 = new ExtHostFileSystemEventService(protocol, new NullLogService(), undefined!).createFileSystemWatcher('**/somethingInteresting', false, false, false);
assert.equal(watcher1.ignoreChangeEvents, false);
assert.equal(watcher1.ignoreCreateEvents, false);
assert.equal(watcher1.ignoreDeleteEvents, false);
assert.strictEqual(watcher1.ignoreChangeEvents, false);
assert.strictEqual(watcher1.ignoreCreateEvents, false);
assert.strictEqual(watcher1.ignoreDeleteEvents, false);
const watcher2 = new ExtHostFileSystemEventService(protocol, new NullLogService(), undefined!).createFileSystemWatcher('**/somethingBoring', true, true, true);
assert.equal(watcher2.ignoreChangeEvents, true);
assert.equal(watcher2.ignoreCreateEvents, true);
assert.equal(watcher2.ignoreDeleteEvents, true);
assert.strictEqual(watcher2.ignoreChangeEvents, true);
assert.strictEqual(watcher2.ignoreCreateEvents, true);
assert.strictEqual(watcher2.ignoreDeleteEvents, true);
});
});

View File

@@ -20,7 +20,7 @@ import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
import { MainThreadCommands } from 'vs/workbench/api/browser/mainThreadCommands';
import { ExtHostDocuments } from 'vs/workbench/api/common/extHostDocuments';
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
import { getDocumentSymbols } from 'vs/editor/contrib/gotoSymbol/documentSymbols';
import { getDocumentSymbols } from 'vs/editor/contrib/documentSymbols/documentSymbols';
import * as modes from 'vs/editor/common/modes';
import { getCodeLensModel } from 'vs/editor/contrib/codelens/codelens';
import { getDefinitionsAtPosition, getImplementationsAtPosition, getTypeDefinitionsAtPosition, getDeclarationsAtPosition, getReferencesAtPosition } from 'vs/editor/contrib/gotoSymbol/goToSymbol';
@@ -127,7 +127,7 @@ suite('ExtHostLanguageFeatures', function () {
// --- outline
test('DocumentSymbols, register/deregister', async () => {
assert.equal(modes.DocumentSymbolProviderRegistry.all(model).length, 0);
assert.strictEqual(modes.DocumentSymbolProviderRegistry.all(model).length, 0);
let d1 = extHost.registerDocumentSymbolProvider(defaultExtension, defaultSelector, new class implements vscode.DocumentSymbolProvider {
provideDocumentSymbols() {
return <vscode.SymbolInformation[]>[];
@@ -135,7 +135,7 @@ suite('ExtHostLanguageFeatures', function () {
});
await rpcProtocol.sync();
assert.equal(modes.DocumentSymbolProviderRegistry.all(model).length, 1);
assert.strictEqual(modes.DocumentSymbolProviderRegistry.all(model).length, 1);
d1.dispose();
return rpcProtocol.sync();
@@ -155,7 +155,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await getDocumentSymbols(model, true, CancellationToken.None);
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
});
test('DocumentSymbols, data conversion', async () => {
@@ -167,10 +167,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await getDocumentSymbols(model, true, CancellationToken.None);
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
let entry = value[0];
assert.equal(entry.name, 'test');
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
assert.strictEqual(entry.name, 'test');
assert.deepStrictEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
});
// --- code lens
@@ -190,7 +190,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await getCodeLensModel(model, CancellationToken.None);
assert.equal(value.lenses.length, 1);
assert.strictEqual(value.lenses.length, 1);
});
test('CodeLens, do not resolve a resolved lens', async () => {
@@ -208,11 +208,11 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await getCodeLensModel(model, CancellationToken.None);
assert.equal(value.lenses.length, 1);
assert.strictEqual(value.lenses.length, 1);
const [data] = value.lenses;
const symbol = await Promise.resolve(data.provider.resolveCodeLens!(model, data.symbol, CancellationToken.None));
assert.equal(symbol!.command!.id, 'id');
assert.equal(symbol!.command!.title, 'Title');
assert.strictEqual(symbol!.command!.id, 'id');
assert.strictEqual(symbol!.command!.title, 'Title');
});
test('CodeLens, missing command', async () => {
@@ -225,11 +225,11 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await getCodeLensModel(model, CancellationToken.None);
assert.equal(value.lenses.length, 1);
assert.strictEqual(value.lenses.length, 1);
let [data] = value.lenses;
const symbol = await Promise.resolve(data.provider.resolveCodeLens!(model, data.symbol, CancellationToken.None));
assert.equal(symbol!.command!.id, 'missing');
assert.equal(symbol!.command!.title, '!!MISSING: command!!');
assert.strictEqual(symbol!.command!.id, 'missing');
assert.strictEqual(symbol!.command!.title, '!!MISSING: command!!');
});
// --- definition
@@ -244,10 +244,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
let value = await getDefinitionsAtPosition(model, new EditorPosition(1, 1), CancellationToken.None);
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
let [entry] = value;
assert.deepEqual(entry.range, { startLineNumber: 2, startColumn: 3, endLineNumber: 4, endColumn: 5 });
assert.equal(entry.uri.toString(), model.uri.toString());
assert.deepStrictEqual(entry.range, { startLineNumber: 2, startColumn: 3, endLineNumber: 4, endColumn: 5 });
assert.strictEqual(entry.uri.toString(), model.uri.toString());
});
test('Definition, one or many', async () => {
@@ -265,7 +265,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await getDefinitionsAtPosition(model, new EditorPosition(1, 1), CancellationToken.None);
assert.equal(value.length, 2);
assert.strictEqual(value.length, 2);
});
test('Definition, registration order', async () => {
@@ -284,10 +284,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await getDefinitionsAtPosition(model, new EditorPosition(1, 1), CancellationToken.None);
assert.equal(value.length, 2);
assert.strictEqual(value.length, 2);
// let [first, second] = value;
assert.equal(value[0].uri.authority, 'second');
assert.equal(value[1].uri.authority, 'first');
assert.strictEqual(value[0].uri.authority, 'second');
assert.strictEqual(value[1].uri.authority, 'first');
});
test('Definition, evil provider', async () => {
@@ -305,7 +305,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await getDefinitionsAtPosition(model, new EditorPosition(1, 1), CancellationToken.None);
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
});
// -- declaration
@@ -320,10 +320,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
let value = await getDeclarationsAtPosition(model, new EditorPosition(1, 1), CancellationToken.None);
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
let [entry] = value;
assert.deepEqual(entry.range, { startLineNumber: 2, startColumn: 3, endLineNumber: 4, endColumn: 5 });
assert.equal(entry.uri.toString(), model.uri.toString());
assert.deepStrictEqual(entry.range, { startLineNumber: 2, startColumn: 3, endLineNumber: 4, endColumn: 5 });
assert.strictEqual(entry.uri.toString(), model.uri.toString());
});
// --- implementation
@@ -338,10 +338,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
let value = await getImplementationsAtPosition(model, new EditorPosition(1, 1), CancellationToken.None);
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
let [entry] = value;
assert.deepEqual(entry.range, { startLineNumber: 2, startColumn: 3, endLineNumber: 4, endColumn: 5 });
assert.equal(entry.uri.toString(), model.uri.toString());
assert.deepStrictEqual(entry.range, { startLineNumber: 2, startColumn: 3, endLineNumber: 4, endColumn: 5 });
assert.strictEqual(entry.uri.toString(), model.uri.toString());
});
// --- type definition
@@ -356,10 +356,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
let value = await getTypeDefinitionsAtPosition(model, new EditorPosition(1, 1), CancellationToken.None);
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
let [entry] = value;
assert.deepEqual(entry.range, { startLineNumber: 2, startColumn: 3, endLineNumber: 4, endColumn: 5 });
assert.equal(entry.uri.toString(), model.uri.toString());
assert.deepStrictEqual(entry.range, { startLineNumber: 2, startColumn: 3, endLineNumber: 4, endColumn: 5 });
assert.strictEqual(entry.uri.toString(), model.uri.toString());
});
// --- extra info
@@ -374,9 +374,9 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
getHover(model, new EditorPosition(1, 1), CancellationToken.None).then(value => {
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
let [entry] = value;
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 5 });
assert.deepStrictEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 5 });
});
});
@@ -391,9 +391,9 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
getHover(model, new EditorPosition(1, 1), CancellationToken.None).then(value => {
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
let [entry] = value;
assert.deepEqual(entry.range, { startLineNumber: 4, startColumn: 1, endLineNumber: 9, endColumn: 8 });
assert.deepStrictEqual(entry.range, { startLineNumber: 4, startColumn: 1, endLineNumber: 9, endColumn: 8 });
});
});
@@ -414,10 +414,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await getHover(model, new EditorPosition(1, 1), CancellationToken.None);
assert.equal(value.length, 2);
assert.strictEqual(value.length, 2);
let [first, second] = (value as modes.Hover[]);
assert.equal(first.contents[0].value, 'registered second');
assert.equal(second.contents[0].value, 'registered first');
assert.strictEqual(first.contents[0].value, 'registered second');
assert.strictEqual(second.contents[0].value, 'registered first');
});
@@ -436,7 +436,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
getHover(model, new EditorPosition(1, 1), CancellationToken.None).then(value => {
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
});
});
@@ -452,10 +452,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = (await getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None))!;
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
const [entry] = value;
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 5 });
assert.equal(entry.kind, modes.DocumentHighlightKind.Text);
assert.deepStrictEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 5 });
assert.strictEqual(entry.kind, modes.DocumentHighlightKind.Text);
});
test('Occurrences, order 1/2', async () => {
@@ -473,10 +473,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = (await getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None))!;
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
const [entry] = value;
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 5 });
assert.equal(entry.kind, modes.DocumentHighlightKind.Text);
assert.deepStrictEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 5 });
assert.strictEqual(entry.kind, modes.DocumentHighlightKind.Text);
});
test('Occurrences, order 2/2', async () => {
@@ -494,10 +494,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = (await getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None))!;
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
const [entry] = value;
assert.deepEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 3 });
assert.equal(entry.kind, modes.DocumentHighlightKind.Text);
assert.deepStrictEqual(entry.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 3 });
assert.strictEqual(entry.kind, modes.DocumentHighlightKind.Text);
});
test('Occurrences, evil provider', async () => {
@@ -516,7 +516,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await getOccurrencesAtPosition(model, new EditorPosition(1, 2), CancellationToken.None);
assert.equal(value!.length, 1);
assert.strictEqual(value!.length, 1);
});
// --- references
@@ -537,10 +537,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
let value = await getReferencesAtPosition(model, new EditorPosition(1, 2), false, CancellationToken.None);
assert.equal(value.length, 2);
assert.strictEqual(value.length, 2);
let [first, second] = value;
assert.equal(first.uri.path, '/second');
assert.equal(second.uri.path, '/first');
assert.strictEqual(first.uri.path, '/second');
assert.strictEqual(second.uri.path, '/first');
});
test('References, data conversion', async () => {
@@ -553,10 +553,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
let value = await getReferencesAtPosition(model, new EditorPosition(1, 2), false, CancellationToken.None);
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
let [item] = value;
assert.deepEqual(item.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
assert.equal(item.uri.toString(), model.uri.toString());
assert.deepStrictEqual(item.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
assert.strictEqual(item.uri.toString(), model.uri.toString());
});
test('References, evil provider', async () => {
@@ -574,7 +574,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await getReferencesAtPosition(model, new EditorPosition(1, 2), false, CancellationToken.None);
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
});
// --- quick fix
@@ -592,12 +592,12 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Manual }, Progress.None, CancellationToken.None);
assert.equal(actions.length, 2);
assert.strictEqual(actions.length, 2);
const [first, second] = actions;
assert.equal(first.action.title, 'Testing1');
assert.equal(first.action.command!.id, 'test1');
assert.equal(second.action.title, 'Testing2');
assert.equal(second.action.command!.id, 'test2');
assert.strictEqual(first.action.title, 'Testing1');
assert.strictEqual(first.action.command!.id, 'test1');
assert.strictEqual(second.action.title, 'Testing2');
assert.strictEqual(second.action.command!.id, 'test2');
});
test('Quick Fix, code action data conversion', async () => {
@@ -616,12 +616,12 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Manual }, Progress.None, CancellationToken.None);
assert.equal(actions.length, 1);
assert.strictEqual(actions.length, 1);
const [first] = actions;
assert.equal(first.action.title, 'Testing1');
assert.equal(first.action.command!.title, 'Testing1Command');
assert.equal(first.action.command!.id, 'test1');
assert.equal(first.action.kind, 'test.scope');
assert.strictEqual(first.action.title, 'Testing1');
assert.strictEqual(first.action.command!.title, 'Testing1Command');
assert.strictEqual(first.action.command!.id, 'test1');
assert.strictEqual(first.action.kind, 'test.scope');
});
@@ -639,7 +639,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Manual }, Progress.None, CancellationToken.None);
assert.equal(actions.length, 1);
assert.strictEqual(actions.length, 1);
});
test('Quick Fix, evil provider', async () => {
@@ -657,7 +657,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Manual }, Progress.None, CancellationToken.None);
assert.equal(actions.length, 1);
assert.strictEqual(actions.length, 1);
});
// --- navigate types
@@ -678,11 +678,11 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
let value = await getWorkspaceSymbols('');
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
const [first] = value;
const [, symbols] = first;
assert.equal(symbols.length, 1);
assert.equal(symbols[0].name, 'testing');
assert.strictEqual(symbols.length, 1);
assert.strictEqual(symbols[0].name, 'testing');
});
// --- rename
@@ -715,7 +715,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await rename(model, new EditorPosition(1, 1), 'newName');
assert.equal(value.rejectReason, 'evil');
assert.strictEqual(value.rejectReason, 'evil');
});
test('Rename, evil provider 2/2', async () => {
@@ -736,7 +736,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await rename(model, new EditorPosition(1, 1), 'newName');
assert.equal(value.edits.length, 1);
assert.strictEqual(value.edits.length, 1);
});
test('Rename, ordering', async () => {
@@ -759,7 +759,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await rename(model, new EditorPosition(1, 1), 'newName');
// least relevant rename provider
assert.equal(value.edits.length, 2);
assert.strictEqual(value.edits.length, 2);
});
test('Multiple RenameProviders don\'t respect all possible PrepareRename handlers, #98352', async function () {
@@ -793,7 +793,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
await rename(model, new EditorPosition(1, 1), 'newName');
assert.deepEqual(called, [true, true, true, false]);
assert.deepStrictEqual(called, [true, true, true, false]);
});
test('Multiple RenameProviders don\'t respect all possible PrepareRename handlers, #98352', async function () {
@@ -825,7 +825,7 @@ suite('ExtHostLanguageFeatures', function () {
await rename(model, new EditorPosition(1, 1), 'newName');
// first provider has NO prepare which means it is taken by default
assert.deepEqual(called, [false, false, true]);
assert.deepStrictEqual(called, [false, false, true]);
});
// --- parameter hints
@@ -863,7 +863,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = await provideSignatureHelp(model, new EditorPosition(1, 1), { triggerKind: modes.SignatureHelpTriggerKind.Invoke, isRetrigger: false }, CancellationToken.None);
assert.equal(value, undefined);
assert.strictEqual(value, undefined);
});
// --- suggestions
@@ -884,8 +884,8 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const { items } = await provideSuggestionItems(model, new EditorPosition(1, 1), new CompletionOptions(undefined, new Set<modes.CompletionItemKind>().add(modes.CompletionItemKind.Snippet)));
assert.equal(items.length, 1);
assert.equal(items[0].completion.insertText, 'testing2');
assert.strictEqual(items.length, 1);
assert.strictEqual(items[0].completion.insertText, 'testing2');
});
test('Suggest, order 2/3', async () => {
@@ -904,8 +904,8 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const { items } = await provideSuggestionItems(model, new EditorPosition(1, 1), new CompletionOptions(undefined, new Set<modes.CompletionItemKind>().add(modes.CompletionItemKind.Snippet)));
assert.equal(items.length, 1);
assert.equal(items[0].completion.insertText, 'weak-selector');
assert.strictEqual(items.length, 1);
assert.strictEqual(items[0].completion.insertText, 'weak-selector');
});
test('Suggest, order 2/3', async () => {
@@ -924,9 +924,9 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const { items } = await provideSuggestionItems(model, new EditorPosition(1, 1), new CompletionOptions(undefined, new Set<modes.CompletionItemKind>().add(modes.CompletionItemKind.Snippet)));
assert.equal(items.length, 2);
assert.equal(items[0].completion.insertText, 'strong-1'); // sort by label
assert.equal(items[1].completion.insertText, 'strong-2');
assert.strictEqual(items.length, 2);
assert.strictEqual(items[0].completion.insertText, 'strong-1'); // sort by label
assert.strictEqual(items[1].completion.insertText, 'strong-2');
});
test('Suggest, evil provider', async () => {
@@ -946,7 +946,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const { items } = await provideSuggestionItems(model, new EditorPosition(1, 1), new CompletionOptions(undefined, new Set<modes.CompletionItemKind>().add(modes.CompletionItemKind.Snippet)));
assert.equal(items[0].container.incomplete, false);
assert.strictEqual(items[0].container.incomplete, false);
});
test('Suggest, CompletionList', async () => {
@@ -959,7 +959,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
provideSuggestionItems(model, new EditorPosition(1, 1), new CompletionOptions(undefined, new Set<modes.CompletionItemKind>().add(modes.CompletionItemKind.Snippet))).then(model => {
assert.equal(model.items[0].container.incomplete, true);
assert.strictEqual(model.items[0].container.incomplete, true);
});
});
@@ -980,13 +980,13 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
let value = (await getDocumentFormattingEditsUntilResult(NullWorkerService, model, { insertSpaces: true, tabSize: 4 }, CancellationToken.None))!;
assert.equal(value.length, 2);
assert.strictEqual(value.length, 2);
let [first, second] = value;
assert.equal(first.text, 'testing');
assert.deepEqual(first.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
assert.equal(second.eol, EndOfLineSequence.LF);
assert.equal(second.text, '');
assert.deepEqual(second.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
assert.strictEqual(first.text, 'testing');
assert.deepStrictEqual(first.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
assert.strictEqual(second.eol, EndOfLineSequence.LF);
assert.strictEqual(second.text, '');
assert.deepStrictEqual(second.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
});
test('Format Doc, evil provider', async () => {
@@ -1022,10 +1022,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
let value = (await getDocumentFormattingEditsUntilResult(NullWorkerService, model, { insertSpaces: true, tabSize: 4 }, CancellationToken.None))!;
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
let [first] = value;
assert.equal(first.text, 'testing');
assert.deepEqual(first.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
assert.strictEqual(first.text, 'testing');
assert.deepStrictEqual(first.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
});
test('Format Range, data conversion', async () => {
@@ -1037,10 +1037,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = (await getDocumentRangeFormattingEditsUntilResult(NullWorkerService, model, new EditorRange(1, 1, 1, 1), { insertSpaces: true, tabSize: 4 }, CancellationToken.None))!;
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
const [first] = value;
assert.equal(first.text, 'testing');
assert.deepEqual(first.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
assert.strictEqual(first.text, 'testing');
assert.deepStrictEqual(first.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
});
test('Format Range, + format_doc', async () => {
@@ -1061,13 +1061,13 @@ suite('ExtHostLanguageFeatures', function () {
}));
await rpcProtocol.sync();
const value = (await getDocumentRangeFormattingEditsUntilResult(NullWorkerService, model, new EditorRange(1, 1, 1, 1), { insertSpaces: true, tabSize: 4 }, CancellationToken.None))!;
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
const [first] = value;
assert.equal(first.text, 'range2');
assert.equal(first.range.startLineNumber, 3);
assert.equal(first.range.startColumn, 4);
assert.equal(first.range.endLineNumber, 5);
assert.equal(first.range.endColumn, 6);
assert.strictEqual(first.text, 'range2');
assert.strictEqual(first.range.startLineNumber, 3);
assert.strictEqual(first.range.startColumn, 4);
assert.strictEqual(first.range.endLineNumber, 5);
assert.strictEqual(first.range.endColumn, 6);
});
test('Format Range, evil provider', async () => {
@@ -1091,10 +1091,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
const value = (await getOnTypeFormattingEdits(NullWorkerService, model, new EditorPosition(1, 1), ';', { insertSpaces: true, tabSize: 2 }))!;
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
const [first] = value;
assert.equal(first.text, ';');
assert.deepEqual(first.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
assert.strictEqual(first.text, ';');
assert.deepStrictEqual(first.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 });
});
test('Links, data conversion', async () => {
@@ -1109,11 +1109,11 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
let { links } = await getLinks(model, CancellationToken.None);
assert.equal(links.length, 1);
assert.strictEqual(links.length, 1);
let [first] = links;
assert.equal(first.url, 'foo:bar#3');
assert.deepEqual(first.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 2, endColumn: 2 });
assert.equal(first.tooltip, 'tooltip');
assert.strictEqual(first.url?.toString(), 'foo:bar#3');
assert.deepStrictEqual(first.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 2, endColumn: 2 });
assert.strictEqual(first.tooltip, 'tooltip');
});
test('Links, evil provider', async () => {
@@ -1132,10 +1132,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
let { links } = await getLinks(model, CancellationToken.None);
assert.equal(links.length, 1);
assert.strictEqual(links.length, 1);
let [first] = links;
assert.equal(first.url, 'foo:bar#3');
assert.deepEqual(first.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 2, endColumn: 2 });
assert.strictEqual(first.url?.toString(), 'foo:bar#3');
assert.deepStrictEqual(first.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 2, endColumn: 2 });
});
test('Document colors, data conversion', async () => {
@@ -1151,10 +1151,10 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
let value = await getColors(model, CancellationToken.None);
assert.equal(value.length, 1);
assert.strictEqual(value.length, 1);
let [first] = value;
assert.deepEqual(first.colorInfo.color, { red: 0.1, green: 0.2, blue: 0.3, alpha: 0.4 });
assert.deepEqual(first.colorInfo.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 21 });
assert.deepStrictEqual(first.colorInfo.color, { red: 0.1, green: 0.2, blue: 0.3, alpha: 0.4 });
assert.deepStrictEqual(first.colorInfo.range, { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 21 });
});
// -- selection ranges
@@ -1171,7 +1171,7 @@ suite('ExtHostLanguageFeatures', function () {
await rpcProtocol.sync();
provideSelectionRanges(model, [new Position(1, 17)], { selectLeadingAndTrailingWhitespace: true }, CancellationToken.None).then(ranges => {
assert.equal(ranges.length, 1);
assert.strictEqual(ranges.length, 1);
assert.ok(ranges[0].length >= 2);
});
});

View File

@@ -101,28 +101,28 @@ suite('ExtHostMessageService', function () {
test('propagte handle on select', async function () {
let service = new MainThreadMessageService(null!, new EmptyNotificationService(notification => {
assert.equal(notification.actions!.primary!.length, 1);
assert.strictEqual(notification.actions!.primary!.length, 1);
platform.setImmediate(() => notification.actions!.primary![0].run());
}), emptyCommandService, emptyDialogService);
const handle = await service.$showMessage(1, 'h', {}, [{ handle: 42, title: 'a thing', isCloseAffordance: true }]);
assert.equal(handle, 42);
assert.strictEqual(handle, 42);
});
suite('modal', () => {
test('calls dialog service', async () => {
const service = new MainThreadMessageService(null!, emptyNotificationService, emptyCommandService, new class extends mock<IDialogService>() {
show(severity: Severity, message: string, buttons: string[]) {
assert.equal(severity, 1);
assert.equal(message, 'h');
assert.equal(buttons.length, 2);
assert.equal(buttons[1], 'Cancel');
assert.strictEqual(severity, 1);
assert.strictEqual(message, 'h');
assert.strictEqual(buttons.length, 2);
assert.strictEqual(buttons[1], 'Cancel');
return Promise.resolve({ choice: 0 });
}
} as IDialogService);
const handle = await service.$showMessage(1, 'h', { modal: true }, [{ handle: 42, title: 'a thing', isCloseAffordance: false }]);
assert.equal(handle, 42);
assert.strictEqual(handle, 42);
});
test('returns undefined when cancelled', async () => {
@@ -133,19 +133,19 @@ suite('ExtHostMessageService', function () {
} as IDialogService);
const handle = await service.$showMessage(1, 'h', { modal: true }, [{ handle: 42, title: 'a thing', isCloseAffordance: false }]);
assert.equal(handle, undefined);
assert.strictEqual(handle, undefined);
});
test('hides Cancel button when not needed', async () => {
const service = new MainThreadMessageService(null!, emptyNotificationService, emptyCommandService, new class extends mock<IDialogService>() {
show(severity: Severity, message: string, buttons: string[]) {
assert.equal(buttons.length, 1);
assert.strictEqual(buttons.length, 1);
return Promise.resolve({ choice: 0 });
}
} as IDialogService);
const handle = await service.$showMessage(1, 'h', { modal: true }, [{ handle: 42, title: 'a thing', isCloseAffordance: true }]);
assert.equal(handle, 42);
assert.strictEqual(handle, 42);
});
});
});

View File

@@ -104,14 +104,14 @@ suite('NotebookCell#Document', function () {
const d1 = extHostDocuments.getDocument(c1.uri);
assert.ok(d1);
assert.equal(d1.languageId, c1.language);
assert.equal(d1.version, 1);
assert.strictEqual(d1.languageId, c1.language);
assert.strictEqual(d1.version, 1);
assert.ok(d1.notebook === notebook.notebookDocument);
const d2 = extHostDocuments.getDocument(c2.uri);
assert.ok(d2);
assert.equal(d2.languageId, c2.language);
assert.equal(d2.version, 1);
assert.strictEqual(d2.languageId, c2.language);
assert.strictEqual(d2.version, 1);
assert.ok(d2.notebook === notebook.notebookDocument);
});
@@ -197,7 +197,7 @@ suite('NotebookCell#Document', function () {
for (let cell of notebook.notebookDocument.cells) {
const doc = extHostDocuments.getDocument(cell.uri);
assert.ok(doc);
assert.equal(extHostDocuments.getDocument(cell.uri).isClosed, false);
assert.strictEqual(extHostDocuments.getDocument(cell.uri).isClosed, false);
docs.push(doc);
addData.push({
EOL: '\n',
@@ -218,7 +218,7 @@ suite('NotebookCell#Document', function () {
// notebook is still open -> cell documents stay open
for (let cell of notebook.notebookDocument.cells) {
assert.ok(extHostDocuments.getDocument(cell.uri));
assert.equal(extHostDocuments.getDocument(cell.uri).isClosed, false);
assert.strictEqual(extHostDocuments.getDocument(cell.uri).isClosed, false);
}
// close notebook -> docs are closed
@@ -227,13 +227,13 @@ suite('NotebookCell#Document', function () {
assert.throws(() => extHostDocuments.getDocument(cell.uri));
}
for (let doc of docs) {
assert.equal(doc.isClosed, true);
assert.strictEqual(doc.isClosed, true);
}
});
test('cell document goes when cell is removed', async function () {
assert.equal(notebook.notebookDocument.cells.length, 2);
assert.strictEqual(notebook.notebookDocument.cells.length, 2);
const [cell1, cell2] = notebook.notebookDocument.cells;
extHostNotebooks.$acceptModelChanged(notebook.uri, {
@@ -246,25 +246,25 @@ suite('NotebookCell#Document', function () {
]
}, false);
assert.equal(notebook.notebookDocument.cells.length, 1);
assert.equal(cell1.document.isClosed, true); // ref still alive!
assert.equal(cell2.document.isClosed, false);
assert.strictEqual(notebook.notebookDocument.cells.length, 1);
assert.strictEqual(cell1.document.isClosed, true); // ref still alive!
assert.strictEqual(cell2.document.isClosed, false);
assert.throws(() => extHostDocuments.getDocument(cell1.uri));
});
test('cell document knows notebook', function () {
for (let cells of notebook.notebookDocument.cells) {
assert.equal(cells.document.notebook === notebook.notebookDocument, true);
assert.strictEqual(cells.document.notebook === notebook.notebookDocument, true);
}
});
test('cell#index', function () {
assert.equal(notebook.notebookDocument.cells.length, 2);
assert.strictEqual(notebook.notebookDocument.cells.length, 2);
const [first, second] = notebook.notebookDocument.cells;
assert.equal(first.index, 0);
assert.equal(second.index, 1);
assert.strictEqual(first.index, 0);
assert.strictEqual(second.index, 1);
// remove first cell
extHostNotebooks.$acceptModelChanged(notebook.uri, {
@@ -275,8 +275,8 @@ suite('NotebookCell#Document', function () {
}]
}, false);
assert.equal(notebook.notebookDocument.cells.length, 1);
assert.equal(second.index, 0);
assert.strictEqual(notebook.notebookDocument.cells.length, 1);
assert.strictEqual(second.index, 0);
extHostNotebooks.$acceptModelChanged(notebookUri, {
versionId: notebook.notebookDocument.version + 1,
@@ -302,7 +302,7 @@ suite('NotebookCell#Document', function () {
}]
}, false);
assert.equal(notebook.notebookDocument.cells.length, 3);
assert.equal(second.index, 2);
assert.strictEqual(notebook.notebookDocument.cells.length, 3);
assert.strictEqual(second.index, 2);
});
});

View File

@@ -91,27 +91,27 @@ suite('NotebookConcatDocument', function () {
test('empty', function () {
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
assert.equal(doc.getText(), '');
assert.equal(doc.version, 0);
assert.strictEqual(doc.getText(), '');
assert.strictEqual(doc.version, 0);
// assert.equal(doc.locationAt(new Position(0, 0)), undefined);
// assert.equal(doc.positionAt(SOME_FAKE_LOCATION?), undefined);
// assert.strictEqual(doc.locationAt(new Position(0, 0)), undefined);
// assert.strictEqual(doc.positionAt(SOME_FAKE_LOCATION?), undefined);
});
function assertLocation(doc: vscode.NotebookConcatTextDocument, pos: Position, expected: Location, reverse = true) {
const actual = doc.locationAt(pos);
assert.equal(actual.uri.toString(), expected.uri.toString());
assert.equal(actual.range.isEqual(expected.range), true);
assert.strictEqual(actual.uri.toString(), expected.uri.toString());
assert.strictEqual(actual.range.isEqual(expected.range), true);
if (reverse) {
// reverse - offset
const offset = doc.offsetAt(pos);
assert.equal(doc.positionAt(offset).isEqual(pos), true);
assert.strictEqual(doc.positionAt(offset).isEqual(pos), true);
// reverse - pos
const actualPosition = doc.positionAt(actual);
assert.equal(actualPosition.isEqual(pos), true);
assert.strictEqual(actualPosition.isEqual(pos), true);
}
}
@@ -151,13 +151,13 @@ suite('NotebookConcatDocument', function () {
}, false);
assert.equal(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
assert.equal(doc.contains(cellUri1), true);
assert.equal(doc.contains(cellUri2), true);
assert.equal(doc.contains(URI.parse('some://miss/path')), false);
assert.strictEqual(doc.contains(cellUri1), true);
assert.strictEqual(doc.contains(cellUri2), true);
assert.strictEqual(doc.contains(URI.parse('some://miss/path')), false);
});
test('location, position mapping', function () {
@@ -189,7 +189,7 @@ suite('NotebookConcatDocument', function () {
}, false);
assert.equal(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
@@ -224,8 +224,8 @@ suite('NotebookConcatDocument', function () {
}
]
}, false);
assert.equal(notebook.notebookDocument.cells.length, 1 + 1);
assert.equal(doc.version, 1);
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 1);
assert.strictEqual(doc.version, 1);
assertLines(doc, 'Hello', 'World', 'Hello World!');
assertLocation(doc, new Position(0, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(0, 0)));
@@ -252,8 +252,8 @@ suite('NotebookConcatDocument', function () {
]
}, false);
assert.equal(notebook.notebookDocument.cells.length, 1 + 2);
assert.equal(doc.version, 2);
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 2);
assert.strictEqual(doc.version, 2);
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
assertLocation(doc, new Position(0, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(0, 0)));
assertLocation(doc, new Position(4, 0), new Location(notebook.notebookDocument.cells[1].uri, new Position(1, 0)));
@@ -271,8 +271,8 @@ suite('NotebookConcatDocument', function () {
}
]
}, false);
assert.equal(notebook.notebookDocument.cells.length, 1 + 1);
assert.equal(doc.version, 3);
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 1);
assert.strictEqual(doc.version, 3);
assertLines(doc, 'Hello', 'World', 'Hello World!');
assertLocation(doc, new Position(0, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(0, 0)));
assertLocation(doc, new Position(2, 2), new Location(notebook.notebookDocument.cells[0].uri, new Position(2, 2)));
@@ -310,8 +310,8 @@ suite('NotebookConcatDocument', function () {
}
]
}, false);
assert.equal(notebook.notebookDocument.cells.length, 1 + 2);
assert.equal(doc.version, 1);
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 2);
assert.strictEqual(doc.version, 1);
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
assertLocation(doc, new Position(0, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(0, 0)));
@@ -322,7 +322,7 @@ suite('NotebookConcatDocument', function () {
// offset math
let cell1End = doc.offsetAt(new Position(2, 12));
assert.equal(doc.positionAt(cell1End).isEqual(new Position(2, 12)), true);
assert.strictEqual(doc.positionAt(cell1End).isEqual(new Position(2, 12)), true);
extHostDocuments.$acceptModelChanged(notebook.notebookDocument.cells[0].uri, {
versionId: 0,
@@ -337,7 +337,7 @@ suite('NotebookConcatDocument', function () {
assertLines(doc, 'Hello', 'World', 'Hi World!', 'Hallo', 'Welt', 'Hallo Welt!');
assertLocation(doc, new Position(2, 12), new Location(notebook.notebookDocument.cells[0].uri, new Position(2, 9)), false);
assert.equal(doc.positionAt(cell1End).isEqual(new Position(3, 2)), true);
assert.strictEqual(doc.positionAt(cell1End).isEqual(new Position(3, 2)), true);
});
@@ -403,12 +403,12 @@ suite('NotebookConcatDocument', function () {
function assertOffsetAtPosition(doc: vscode.NotebookConcatTextDocument, offset: number, expected: { line: number, character: number }, reverse = true) {
const actual = doc.positionAt(offset);
assert.equal(actual.line, expected.line);
assert.equal(actual.character, expected.character);
assert.strictEqual(actual.line, expected.line);
assert.strictEqual(actual.character, expected.character);
if (reverse) {
const actualOffset = doc.offsetAt(actual);
assert.equal(actualOffset, offset);
assert.strictEqual(actualOffset, offset);
}
}
@@ -441,7 +441,7 @@ suite('NotebookConcatDocument', function () {
]
}, false);
assert.equal(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
@@ -457,16 +457,16 @@ suite('NotebookConcatDocument', function () {
function assertLocationAtPosition(doc: vscode.NotebookConcatTextDocument, pos: { line: number, character: number }, expected: { uri: URI, line: number, character: number }, reverse = true) {
const actual = doc.locationAt(new Position(pos.line, pos.character));
assert.equal(actual.uri.toString(), expected.uri.toString());
assert.equal(actual.range.start.line, expected.line);
assert.equal(actual.range.end.line, expected.line);
assert.equal(actual.range.start.character, expected.character);
assert.equal(actual.range.end.character, expected.character);
assert.strictEqual(actual.uri.toString(), expected.uri.toString());
assert.strictEqual(actual.range.start.line, expected.line);
assert.strictEqual(actual.range.end.line, expected.line);
assert.strictEqual(actual.range.start.character, expected.character);
assert.strictEqual(actual.range.end.character, expected.character);
if (reverse) {
const actualPos = doc.positionAt(actual);
assert.equal(actualPos.line, pos.line);
assert.equal(actualPos.character, pos.character);
assert.strictEqual(actualPos.line, pos.line);
assert.strictEqual(actualPos.character, pos.character);
}
}
@@ -498,7 +498,7 @@ suite('NotebookConcatDocument', function () {
]
}, false);
assert.equal(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
@@ -539,14 +539,14 @@ suite('NotebookConcatDocument', function () {
]
}, false);
assert.equal(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
assert.equal(doc.getText(new Range(0, 0, 0, 0)), '');
assert.equal(doc.getText(new Range(0, 0, 1, 0)), 'Hello\n');
assert.equal(doc.getText(new Range(2, 0, 4, 0)), 'Hello World!\nHallo\n');
assert.strictEqual(doc.getText(new Range(0, 0, 0, 0)), '');
assert.strictEqual(doc.getText(new Range(0, 0, 1, 0)), 'Hello\n');
assert.strictEqual(doc.getText(new Range(2, 0, 4, 0)), 'Hello World!\nHallo\n');
});
test('validateRange/Position', function () {
@@ -577,15 +577,15 @@ suite('NotebookConcatDocument', function () {
]
}, false);
assert.equal(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
assert.strictEqual(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
function assertPosition(actual: vscode.Position, expectedLine: number, expectedCh: number) {
assert.equal(actual.line, expectedLine);
assert.equal(actual.character, expectedCh);
assert.strictEqual(actual.line, expectedLine);
assert.strictEqual(actual.character, expectedCh);
}

View File

@@ -4,24 +4,22 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { MirroredTestCollection, OwnedTestCollection, SingleUseTestCollection } from 'vs/workbench/api/common/extHostTesting';
import { MirroredTestCollection, TestItemFilteredWrapper } from 'vs/workbench/api/common/extHostTesting';
import * as convert from 'vs/workbench/api/common/extHostTypeConverters';
import { TestRunState, TestState } from 'vs/workbench/api/common/extHostTypes';
import { TestDiffOpType, TestsDiff } from 'vs/workbench/contrib/testing/common/testCollection';
import { TestChangeEvent, TestItem } from 'vscode';
const stubTest = (label: string): TestItem => ({
label,
location: undefined,
state: new TestState(TestRunState.Unset),
debuggable: true,
runnable: true,
description: ''
});
import { TestDiffOpType } from 'vs/workbench/contrib/testing/common/testCollection';
import { stubTest, testStubs } from 'vs/workbench/contrib/testing/common/testStubs';
import { TestOwnedTestCollection, TestSingleUseCollection } from 'vs/workbench/contrib/testing/test/common/ownedTestCollection';
import { TestChangeEvent, TestItem, TextDocument } from 'vscode';
import { URI } from 'vs/base/common/uri';
import { Location } from 'vs/editor/common/modes';
import { Range } from 'vs/editor/common/core/range';
const simplify = (item: TestItem) => {
if ('toJSON' in item) {
item = (item as any).toJSON();
delete (item as any).id;
delete (item as any).providerId;
delete (item as any).testId;
}
return { ...item, children: undefined };
@@ -41,44 +39,6 @@ const assertTreeListEqual = (a: ReadonlyArray<Readonly<TestItem>>, b: ReadonlyAr
a.forEach((_, i) => assertTreesEqual(a[i], b[i]));
};
const stubNestedTests = () => ({
...stubTest('root'),
children: [
{ ...stubTest('a'), children: [stubTest('aa'), stubTest('ab')] },
stubTest('b'),
]
});
class TestOwnedTestCollection extends OwnedTestCollection {
public get idToInternal() {
return this.testIdToInternal;
}
public createForHierarchy(publishDiff: (diff: TestsDiff) => void = () => undefined) {
return new TestSingleUseCollection(this.testIdToInternal, publishDiff);
}
}
class TestSingleUseCollection extends SingleUseTestCollection {
private idCounter = 0;
public get itemToInternal() {
return this.testItemToInternal;
}
public get currentDiff() {
return this.diff;
}
protected getId() {
return String(this.idCounter++);
}
public setDiff(diff: TestsDiff) {
this.diff = diff;
}
}
class TestMirroredCollection extends MirroredTestCollection {
public changeEvent!: TestChangeEvent;
@@ -102,37 +62,37 @@ suite('ExtHost Testing', () => {
teardown(() => {
single.dispose();
assert.deepEqual(owned.idToInternal.size, 0, 'expected owned ids to be empty after dispose');
assert.strictEqual(owned.idToInternal.size, 0, 'expected owned ids to be empty after dispose');
});
suite('OwnedTestCollection', () => {
test('adds a root recursively', () => {
const tests = stubNestedTests();
const tests = testStubs.nested();
single.addRoot(tests, 'pid');
assert.deepStrictEqual(single.collectDiff(), [
[TestDiffOpType.Add, { id: '0', providerId: 'pid', parent: null, item: convert.TestItem.from(stubTest('root')) }],
[TestDiffOpType.Add, { id: '1', providerId: 'pid', parent: '0', item: convert.TestItem.from(stubTest('a')) }],
[TestDiffOpType.Add, { id: '2', providerId: 'pid', parent: '1', item: convert.TestItem.from(stubTest('aa')) }],
[TestDiffOpType.Add, { id: '3', providerId: 'pid', parent: '1', item: convert.TestItem.from(stubTest('ab')) }],
[TestDiffOpType.Add, { id: '4', providerId: 'pid', parent: '0', item: convert.TestItem.from(stubTest('b')) }],
[TestDiffOpType.Add, { id: '1', providerId: 'pid', parent: '0', item: convert.TestItem.from(stubTest('a'), 'root') }],
[TestDiffOpType.Add, { id: '2', providerId: 'pid', parent: '1', item: convert.TestItem.from(stubTest('aa'), 'root\0a') }],
[TestDiffOpType.Add, { id: '3', providerId: 'pid', parent: '1', item: convert.TestItem.from(stubTest('ab'), 'root\0a') }],
[TestDiffOpType.Add, { id: '4', providerId: 'pid', parent: '0', item: convert.TestItem.from(stubTest('b'), 'root') }],
]);
});
test('no-ops if items not changed', () => {
const tests = stubNestedTests();
const tests = testStubs.nested();
single.addRoot(tests, 'pid');
single.collectDiff();
assert.deepStrictEqual(single.collectDiff(), []);
});
test('watches property mutations', () => {
const tests = stubNestedTests();
const tests = testStubs.nested();
single.addRoot(tests, 'pid');
single.collectDiff();
tests.children![0].description = 'Hello world'; /* item a */
single.onItemChange(tests, 'pid');
assert.deepStrictEqual(single.collectDiff(), [
[TestDiffOpType.Update, { id: '1', parent: '0', providerId: 'pid', item: convert.TestItem.from({ ...stubTest('a'), description: 'Hello world' }) }],
[TestDiffOpType.Update, { id: '1', parent: '0', providerId: 'pid', item: convert.TestItem.from({ ...stubTest('a'), description: 'Hello world' }, 'root') }],
]);
single.onItemChange(tests, 'pid');
@@ -140,7 +100,7 @@ suite('ExtHost Testing', () => {
});
test('removes children', () => {
const tests = stubNestedTests();
const tests = testStubs.nested();
single.addRoot(tests, 'pid');
single.collectDiff();
tests.children!.splice(0, 1);
@@ -154,7 +114,7 @@ suite('ExtHost Testing', () => {
});
test('adds new children', () => {
const tests = stubNestedTests();
const tests = testStubs.nested();
single.addRoot(tests, 'pid');
single.collectDiff();
const child = stubTest('ac');
@@ -162,7 +122,7 @@ suite('ExtHost Testing', () => {
single.onItemChange(tests, 'pid');
assert.deepStrictEqual(single.collectDiff(), [
[TestDiffOpType.Add, { id: '5', providerId: 'pid', parent: '1', item: convert.TestItem.from(child) }],
[TestDiffOpType.Add, { id: '5', providerId: 'pid', parent: '1', item: convert.TestItem.from(child, 'root\0a') }],
]);
assert.deepStrictEqual([...owned.idToInternal.keys()].sort(), ['0', '1', '2', '3', '4', '5']);
assert.strictEqual(single.itemToInternal.size, 6);
@@ -174,7 +134,7 @@ suite('ExtHost Testing', () => {
setup(() => m = new TestMirroredCollection());
test('mirrors creation of the root', () => {
const tests = stubNestedTests();
const tests = testStubs.nested();
single.addRoot(tests, 'pid');
m.apply(single.collectDiff());
assertTreesEqual(m.rootTestItems[0], owned.getTestById('0')!.actual);
@@ -182,7 +142,7 @@ suite('ExtHost Testing', () => {
});
test('mirrors node deletion', () => {
const tests = stubNestedTests();
const tests = testStubs.nested();
single.addRoot(tests, 'pid');
m.apply(single.collectDiff());
tests.children!.splice(0, 1);
@@ -194,7 +154,7 @@ suite('ExtHost Testing', () => {
});
test('mirrors node addition', () => {
const tests = stubNestedTests();
const tests = testStubs.nested();
single.addRoot(tests, 'pid');
m.apply(single.collectDiff());
tests.children![0].children!.push(stubTest('ac'));
@@ -206,7 +166,7 @@ suite('ExtHost Testing', () => {
});
test('mirrors node update', () => {
const tests = stubNestedTests();
const tests = testStubs.nested();
single.addRoot(tests, 'pid');
m.apply(single.collectDiff());
tests.children![0].description = 'Hello world'; /* item a */
@@ -217,9 +177,9 @@ suite('ExtHost Testing', () => {
});
suite('MirroredChangeCollector', () => {
let tests = stubNestedTests();
let tests = testStubs.nested();
setup(() => {
tests = stubNestedTests();
tests = testStubs.nested();
single.addRoot(tests, 'pid');
m.apply(single.collectDiff());
});
@@ -264,7 +224,7 @@ suite('ExtHost Testing', () => {
});
test('is a no-op if a node is added and removed', () => {
const nested = stubNestedTests();
const nested = testStubs.nested();
tests.children.push(nested);
single.onItemChange(tests, 'pid');
tests.children.pop();
@@ -306,5 +266,141 @@ suite('ExtHost Testing', () => {
assert.strictEqual(m.changeEvent.commonChangeAncestor?.label, 'root');
});
});
suite('TestItemFilteredWrapper', () => {
const stubTestWithLocation = (label: string, location: Location): TestItem => {
const t = stubTest(label);
t.location = location as any;
return t;
};
const location1: Location = {
range: new Range(0, 0, 0, 0),
uri: URI.parse('file:///foo.ts')
};
const location2: Location = {
range: new Range(0, 0, 0, 0),
uri: URI.parse('file:///bar.ts')
};
const location3: Location = {
range: new Range(0, 0, 0, 0),
uri: URI.parse('file:///baz.ts')
};
const textDocumentFilter = {
uri: location1.uri
} as TextDocument;
let testsWithLocation: TestItem;
setup(() => {
testsWithLocation = {
...stubTest('root'),
children: [
{
...stubTestWithLocation('a', location1),
children: [stubTestWithLocation('aa', location1), stubTestWithLocation('ab', location1)]
},
{
...stubTestWithLocation('b', location2),
children: [stubTestWithLocation('ba', location2), stubTestWithLocation('bb', location2)]
},
{
...stubTestWithLocation('b', location3),
}
],
};
});
teardown(() => {
TestItemFilteredWrapper.removeFilter(textDocumentFilter);
});
test('gets all actual properties', () => {
const testItem: TestItem = stubTest('test1');
const wrapper: TestItemFilteredWrapper = TestItemFilteredWrapper.getWrapperForTestItem(testItem, textDocumentFilter);
assert.strictEqual(testItem.debuggable, wrapper.debuggable);
assert.strictEqual(testItem.description, wrapper.description);
assert.strictEqual(testItem.label, wrapper.label);
assert.strictEqual(testItem.location, wrapper.location);
assert.strictEqual(testItem.runnable, wrapper.runnable);
assert.strictEqual(testItem.state, wrapper.state);
});
test('gets no children if nothing matches Uri filter', () => {
let tests: TestItem = testStubs.nested();
const wrapper = TestItemFilteredWrapper.getWrapperForTestItem(tests, textDocumentFilter);
assert.strictEqual(wrapper.children.length, 0);
});
test('filter is applied to children', () => {
const wrapper = TestItemFilteredWrapper.getWrapperForTestItem(testsWithLocation, textDocumentFilter);
assert.strictEqual(wrapper.label, 'root');
assert.strictEqual(wrapper.children.length, 1);
assert.strictEqual(wrapper.children[0] instanceof TestItemFilteredWrapper, true);
assert.strictEqual(wrapper.children[0].label, 'a');
});
test('can get if node has matching filter', () => {
const rootWrapper = TestItemFilteredWrapper.getWrapperForTestItem(testsWithLocation, textDocumentFilter);
const invisible = testsWithLocation.children![1];
const invisibleWrapper = TestItemFilteredWrapper.getWrapperForTestItem(invisible, textDocumentFilter);
const visible = testsWithLocation.children![0];
const visibleWrapper = TestItemFilteredWrapper.getWrapperForTestItem(visible, textDocumentFilter);
// The root is always visible
assert.strictEqual(rootWrapper.hasNodeMatchingFilter, true);
assert.strictEqual(invisibleWrapper.hasNodeMatchingFilter, false);
assert.strictEqual(visibleWrapper.hasNodeMatchingFilter, true);
});
test('can get visible parent', () => {
const rootWrapper = TestItemFilteredWrapper.getWrapperForTestItem(testsWithLocation, textDocumentFilter);
const invisible = testsWithLocation.children![1];
const invisibleWrapper = TestItemFilteredWrapper.getWrapperForTestItem(invisible, textDocumentFilter);
const visible = testsWithLocation.children![0];
const visibleWrapper = TestItemFilteredWrapper.getWrapperForTestItem(visible, textDocumentFilter);
// The root is always visible
assert.strictEqual(rootWrapper.visibleParent, rootWrapper);
assert.strictEqual(invisibleWrapper.visibleParent, rootWrapper);
assert.strictEqual(visibleWrapper.visibleParent, visibleWrapper);
});
test('can reset cached value of hasNodeMatchingFilter', () => {
TestItemFilteredWrapper.getWrapperForTestItem(testsWithLocation, textDocumentFilter);
const invisible = testsWithLocation.children![1];
const invisibleWrapper = TestItemFilteredWrapper.getWrapperForTestItem(invisible, textDocumentFilter);
assert.strictEqual(invisibleWrapper.hasNodeMatchingFilter, false);
invisible.location = location1 as any;
assert.strictEqual(invisibleWrapper.hasNodeMatchingFilter, false);
invisibleWrapper.reset();
assert.strictEqual(invisibleWrapper.hasNodeMatchingFilter, true);
});
test('can reset cached value of hasNodeMatchingFilter of parents up to visible parent', () => {
const rootWrapper = TestItemFilteredWrapper.getWrapperForTestItem(testsWithLocation, textDocumentFilter);
const invisibleParent = testsWithLocation.children![1];
const invisibleParentWrapper = TestItemFilteredWrapper.getWrapperForTestItem(invisibleParent, textDocumentFilter);
const invisible = invisibleParent.children![1];
const invisibleWrapper = TestItemFilteredWrapper.getWrapperForTestItem(invisible, textDocumentFilter);
assert.strictEqual(invisibleParentWrapper.hasNodeMatchingFilter, false);
invisible.location = location1 as any;
assert.strictEqual(invisibleParentWrapper.hasNodeMatchingFilter, false);
invisibleWrapper.reset();
assert.strictEqual(invisibleParentWrapper.hasNodeMatchingFilter, true);
// the root should be undefined due to the reset.
assert.strictEqual((rootWrapper as any).matchesFilter, undefined);
});
});
});
});

View File

@@ -11,6 +11,7 @@ import { ExtHostDocumentData } from 'vs/workbench/api/common/extHostDocumentData
import { URI } from 'vs/base/common/uri';
import { mock } from 'vs/base/test/common/mock';
import { NullLogService } from 'vs/platform/log/common/log';
import { Lazy } from 'vs/base/common/lazy';
suite('ExtHostTextEditor', () => {
@@ -20,21 +21,21 @@ suite('ExtHostTextEditor', () => {
], '\n', 1, 'text', false);
setup(() => {
editor = new ExtHostTextEditor('fake', null!, new NullLogService(), doc, [], { cursorStyle: 0, insertSpaces: true, lineNumbers: 1, tabSize: 4, indentSize: 4 }, [], 1);
editor = new ExtHostTextEditor('fake', null!, new NullLogService(), new Lazy(() => doc.document), [], { cursorStyle: 0, insertSpaces: true, lineNumbers: 1, tabSize: 4 }, [], 1);
});
test('disposed editor', () => {
assert.ok(editor.document);
assert.ok(editor.value.document);
editor._acceptViewColumn(3);
assert.equal(3, editor.viewColumn);
assert.strictEqual(3, editor.value.viewColumn);
editor.dispose();
assert.throws(() => editor._acceptViewColumn(2));
assert.equal(3, editor.viewColumn);
assert.strictEqual(3, editor.value.viewColumn);
assert.ok(editor.document);
assert.ok(editor.value.document);
assert.throws(() => editor._acceptOptions(null!));
assert.throws(() => editor._acceptSelections([]));
});
@@ -47,16 +48,16 @@ suite('ExtHostTextEditor', () => {
applyCount += 1;
return Promise.resolve(true);
}
}, new NullLogService(), doc, [], { cursorStyle: 0, insertSpaces: true, lineNumbers: 1, tabSize: 4, indentSize: 4 }, [], 1);
}, new NullLogService(), new Lazy(() => doc.document), [], { cursorStyle: 0, insertSpaces: true, lineNumbers: 1, tabSize: 4 }, [], 1);
await editor.edit(edit => { });
assert.equal(applyCount, 0);
await editor.value.edit(edit => { });
assert.strictEqual(applyCount, 0);
await editor.edit(edit => { edit.setEndOfLine(1); });
assert.equal(applyCount, 1);
await editor.value.edit(edit => { edit.setEndOfLine(1); });
assert.strictEqual(applyCount, 1);
await editor.edit(edit => { edit.delete(new Range(0, 0, 1, 1)); });
assert.equal(applyCount, 2);
await editor.value.edit(edit => { edit.delete(new Range(0, 0, 1, 1)); });
assert.strictEqual(applyCount, 2);
});
});
@@ -70,7 +71,7 @@ suite('ExtHostTextEditorOptions', () => {
let mockProxy: MainThreadTextEditorsShape = {
dispose: undefined!,
$trySetOptions: (id: string, options: ITextEditorConfigurationUpdate) => {
assert.equal(id, '1');
assert.strictEqual(id, '1');
calls.push(options);
return Promise.resolve(undefined);
},
@@ -89,7 +90,6 @@ suite('ExtHostTextEditorOptions', () => {
};
opts = new ExtHostTextEditorOptions(mockProxy, '1', {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
@@ -103,349 +103,210 @@ suite('ExtHostTextEditorOptions', () => {
function assertState(opts: ExtHostTextEditorOptions, expected: IResolvedTextEditorConfiguration): void {
let actual = {
tabSize: opts.tabSize,
indentSize: opts.indentSize,
insertSpaces: opts.insertSpaces,
cursorStyle: opts.cursorStyle,
lineNumbers: opts.lineNumbers
tabSize: opts.value.tabSize,
insertSpaces: opts.value.insertSpaces,
cursorStyle: opts.value.cursorStyle,
lineNumbers: opts.value.lineNumbers
};
assert.deepEqual(actual, expected);
assert.deepStrictEqual(actual, expected);
}
test('can set tabSize to the same value', () => {
opts.tabSize = 4;
opts.value.tabSize = 4;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, []);
assert.deepStrictEqual(calls, []);
});
test('can change tabSize to positive integer', () => {
opts.tabSize = 1;
opts.value.tabSize = 1;
assertState(opts, {
tabSize: 1,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, [{ tabSize: 1 }]);
assert.deepStrictEqual(calls, [{ tabSize: 1 }]);
});
test('can change tabSize to positive float', () => {
opts.tabSize = 2.3;
opts.value.tabSize = 2.3;
assertState(opts, {
tabSize: 2,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, [{ tabSize: 2 }]);
assert.deepStrictEqual(calls, [{ tabSize: 2 }]);
});
test('can change tabSize to a string number', () => {
opts.tabSize = '2';
opts.value.tabSize = '2';
assertState(opts, {
tabSize: 2,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, [{ tabSize: 2 }]);
assert.deepStrictEqual(calls, [{ tabSize: 2 }]);
});
test('tabSize can request indentation detection', () => {
opts.tabSize = 'auto';
opts.value.tabSize = 'auto';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, [{ tabSize: 'auto' }]);
assert.deepStrictEqual(calls, [{ tabSize: 'auto' }]);
});
test('ignores invalid tabSize 1', () => {
opts.tabSize = null!;
opts.value.tabSize = null!;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, []);
assert.deepStrictEqual(calls, []);
});
test('ignores invalid tabSize 2', () => {
opts.tabSize = -5;
opts.value.tabSize = -5;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, []);
assert.deepStrictEqual(calls, []);
});
test('ignores invalid tabSize 3', () => {
opts.tabSize = 'hello';
opts.value.tabSize = 'hello';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, []);
assert.deepStrictEqual(calls, []);
});
test('ignores invalid tabSize 4', () => {
opts.tabSize = '-17';
opts.value.tabSize = '-17';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, []);
});
test('can set indentSize to the same value', () => {
opts.indentSize = 4;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, []);
});
test('can change indentSize to positive integer', () => {
opts.indentSize = 1;
assertState(opts, {
tabSize: 4,
indentSize: 1,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, [{ indentSize: 1 }]);
});
test('can change indentSize to positive float', () => {
opts.indentSize = 2.3;
assertState(opts, {
tabSize: 4,
indentSize: 2,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, [{ indentSize: 2 }]);
});
test('can change indentSize to a string number', () => {
opts.indentSize = '2';
assertState(opts, {
tabSize: 4,
indentSize: 2,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, [{ indentSize: 2 }]);
});
test('indentSize can request to use tabSize', () => {
opts.indentSize = 'tabSize';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, [{ indentSize: 'tabSize' }]);
});
test('indentSize cannot request indentation detection', () => {
opts.indentSize = 'auto';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, []);
});
test('ignores invalid indentSize 1', () => {
opts.indentSize = null!;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, []);
});
test('ignores invalid indentSize 2', () => {
opts.indentSize = -5;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, []);
});
test('ignores invalid indentSize 3', () => {
opts.indentSize = 'hello';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, []);
});
test('ignores invalid indentSize 4', () => {
opts.indentSize = '-17';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, []);
assert.deepStrictEqual(calls, []);
});
test('can set insertSpaces to the same value', () => {
opts.insertSpaces = false;
opts.value.insertSpaces = false;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, []);
assert.deepStrictEqual(calls, []);
});
test('can set insertSpaces to boolean', () => {
opts.insertSpaces = true;
opts.value.insertSpaces = true;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: true,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, [{ insertSpaces: true }]);
assert.deepStrictEqual(calls, [{ insertSpaces: true }]);
});
test('can set insertSpaces to false string', () => {
opts.insertSpaces = 'false';
opts.value.insertSpaces = 'false';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, []);
assert.deepStrictEqual(calls, []);
});
test('can set insertSpaces to truey', () => {
opts.insertSpaces = 'hello';
opts.value.insertSpaces = 'hello';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: true,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, [{ insertSpaces: true }]);
assert.deepStrictEqual(calls, [{ insertSpaces: true }]);
});
test('insertSpaces can request indentation detection', () => {
opts.insertSpaces = 'auto';
opts.value.insertSpaces = 'auto';
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, [{ insertSpaces: 'auto' }]);
assert.deepStrictEqual(calls, [{ insertSpaces: 'auto' }]);
});
test('can set cursorStyle to same value', () => {
opts.cursorStyle = TextEditorCursorStyle.Line;
opts.value.cursorStyle = TextEditorCursorStyle.Line;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, []);
assert.deepStrictEqual(calls, []);
});
test('can change cursorStyle', () => {
opts.cursorStyle = TextEditorCursorStyle.Block;
opts.value.cursorStyle = TextEditorCursorStyle.Block;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Block,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, [{ cursorStyle: TextEditorCursorStyle.Block }]);
assert.deepStrictEqual(calls, [{ cursorStyle: TextEditorCursorStyle.Block }]);
});
test('can set lineNumbers to same value', () => {
opts.lineNumbers = TextEditorLineNumbersStyle.On;
opts.value.lineNumbers = TextEditorLineNumbersStyle.On;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, []);
assert.deepStrictEqual(calls, []);
});
test('can change lineNumbers', () => {
opts.lineNumbers = TextEditorLineNumbersStyle.Off;
opts.value.lineNumbers = TextEditorLineNumbersStyle.Off;
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.Off
});
assert.deepEqual(calls, [{ lineNumbers: RenderLineNumbersType.Off }]);
assert.deepStrictEqual(calls, [{ lineNumbers: RenderLineNumbersType.Off }]);
});
test('can do bulk updates 0', () => {
@@ -457,12 +318,11 @@ suite('ExtHostTextEditorOptions', () => {
});
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, []);
assert.deepStrictEqual(calls, []);
});
test('can do bulk updates 1', () => {
@@ -472,12 +332,11 @@ suite('ExtHostTextEditorOptions', () => {
});
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: true,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, [{ tabSize: 'auto', insertSpaces: true }]);
assert.deepStrictEqual(calls, [{ tabSize: 'auto', insertSpaces: true }]);
});
test('can do bulk updates 2', () => {
@@ -487,12 +346,11 @@ suite('ExtHostTextEditorOptions', () => {
});
assertState(opts, {
tabSize: 3,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Line,
lineNumbers: RenderLineNumbersType.On
});
assert.deepEqual(calls, [{ tabSize: 3, insertSpaces: 'auto' }]);
assert.deepStrictEqual(calls, [{ tabSize: 3, insertSpaces: 'auto' }]);
});
test('can do bulk updates 3', () => {
@@ -502,12 +360,11 @@ suite('ExtHostTextEditorOptions', () => {
});
assertState(opts, {
tabSize: 4,
indentSize: 4,
insertSpaces: false,
cursorStyle: TextEditorCursorStyle.Block,
lineNumbers: RenderLineNumbersType.Relative
});
assert.deepEqual(calls, [{ cursorStyle: TextEditorCursorStyle.Block, lineNumbers: RenderLineNumbersType.Relative }]);
assert.deepStrictEqual(calls, [{ cursorStyle: TextEditorCursorStyle.Block, lineNumbers: RenderLineNumbersType.Relative }]);
});
});

View File

@@ -91,24 +91,24 @@ suite.skip('ExtHostTreeView', function () {
return testObject.$getChildren('testNodeTreeProvider')
.then(elements => {
const actuals = elements.map(e => e.handle);
assert.deepEqual(actuals, ['0/0:a', '0/0:b']);
assert.deepStrictEqual(actuals, ['0/0:a', '0/0:b']);
return Promise.all([
testObject.$getChildren('testNodeTreeProvider', '0/0:a')
.then(children => {
const actuals = children.map(e => e.handle);
assert.deepEqual(actuals, ['0/0:a/0:aa', '0/0:a/0:ab']);
assert.deepStrictEqual(actuals, ['0/0:a/0:aa', '0/0:a/0:ab']);
return Promise.all([
testObject.$getChildren('testNodeTreeProvider', '0/0:a/0:aa').then(children => assert.equal(children.length, 0)),
testObject.$getChildren('testNodeTreeProvider', '0/0:a/0:ab').then(children => assert.equal(children.length, 0))
testObject.$getChildren('testNodeTreeProvider', '0/0:a/0:aa').then(children => assert.strictEqual(children.length, 0)),
testObject.$getChildren('testNodeTreeProvider', '0/0:a/0:ab').then(children => assert.strictEqual(children.length, 0))
]);
}),
testObject.$getChildren('testNodeTreeProvider', '0/0:b')
.then(children => {
const actuals = children.map(e => e.handle);
assert.deepEqual(actuals, ['0/0:b/0:ba', '0/0:b/0:bb']);
assert.deepStrictEqual(actuals, ['0/0:b/0:ba', '0/0:b/0:bb']);
return Promise.all([
testObject.$getChildren('testNodeTreeProvider', '0/0:b/0:ba').then(children => assert.equal(children.length, 0)),
testObject.$getChildren('testNodeTreeProvider', '0/0:b/0:bb').then(children => assert.equal(children.length, 0))
testObject.$getChildren('testNodeTreeProvider', '0/0:b/0:ba').then(children => assert.strictEqual(children.length, 0)),
testObject.$getChildren('testNodeTreeProvider', '0/0:b/0:bb').then(children => assert.strictEqual(children.length, 0))
]);
})
]);
@@ -119,24 +119,24 @@ suite.skip('ExtHostTreeView', function () {
return testObject.$getChildren('testNodeWithIdTreeProvider')
.then(elements => {
const actuals = elements.map(e => e.handle);
assert.deepEqual(actuals, ['1/a', '1/b']);
assert.deepStrictEqual(actuals, ['1/a', '1/b']);
return Promise.all([
testObject.$getChildren('testNodeWithIdTreeProvider', '1/a')
.then(children => {
const actuals = children.map(e => e.handle);
assert.deepEqual(actuals, ['1/aa', '1/ab']);
assert.deepStrictEqual(actuals, ['1/aa', '1/ab']);
return Promise.all([
testObject.$getChildren('testNodeWithIdTreeProvider', '1/aa').then(children => assert.equal(children.length, 0)),
testObject.$getChildren('testNodeWithIdTreeProvider', '1/ab').then(children => assert.equal(children.length, 0))
testObject.$getChildren('testNodeWithIdTreeProvider', '1/aa').then(children => assert.strictEqual(children.length, 0)),
testObject.$getChildren('testNodeWithIdTreeProvider', '1/ab').then(children => assert.strictEqual(children.length, 0))
]);
}),
testObject.$getChildren('testNodeWithIdTreeProvider', '1/b')
.then(children => {
const actuals = children.map(e => e.handle);
assert.deepEqual(actuals, ['1/ba', '1/bb']);
assert.deepStrictEqual(actuals, ['1/ba', '1/bb']);
return Promise.all([
testObject.$getChildren('testNodeWithIdTreeProvider', '1/ba').then(children => assert.equal(children.length, 0)),
testObject.$getChildren('testNodeWithIdTreeProvider', '1/bb').then(children => assert.equal(children.length, 0))
testObject.$getChildren('testNodeWithIdTreeProvider', '1/ba').then(children => assert.strictEqual(children.length, 0)),
testObject.$getChildren('testNodeWithIdTreeProvider', '1/bb').then(children => assert.strictEqual(children.length, 0))
]);
})
]);
@@ -146,7 +146,7 @@ suite.skip('ExtHostTreeView', function () {
test('construct highlights tree', () => {
return testObject.$getChildren('testNodeWithHighlightsTreeProvider')
.then(elements => {
assert.deepEqual(removeUnsetKeys(elements), [{
assert.deepStrictEqual(removeUnsetKeys(elements), [{
handle: '1/a',
label: { label: 'a', highlights: [[0, 2], [3, 5]] },
collapsibleState: TreeItemCollapsibleState.Collapsed
@@ -158,7 +158,7 @@ suite.skip('ExtHostTreeView', function () {
return Promise.all([
testObject.$getChildren('testNodeWithHighlightsTreeProvider', '1/a')
.then(children => {
assert.deepEqual(removeUnsetKeys(children), [{
assert.deepStrictEqual(removeUnsetKeys(children), [{
handle: '1/aa',
parentHandle: '1/a',
label: { label: 'aa', highlights: [[0, 2], [3, 5]] },
@@ -172,7 +172,7 @@ suite.skip('ExtHostTreeView', function () {
}),
testObject.$getChildren('testNodeWithHighlightsTreeProvider', '1/b')
.then(children => {
assert.deepEqual(removeUnsetKeys(children), [{
assert.deepStrictEqual(removeUnsetKeys(children), [{
handle: '1/ba',
parentHandle: '1/b',
label: { label: 'ba', highlights: [[0, 2], [3, 5]] },
@@ -196,15 +196,17 @@ suite.skip('ExtHostTreeView', function () {
'aa': {},
'ba': {}
};
let caughtExpectedError = false;
target.onRefresh.event(() => {
testObject.$getChildren('testNodeWithIdTreeProvider')
.then(elements => {
const actuals = elements.map(e => e.handle);
assert.deepEqual(actuals, ['1/a', '1/b']);
assert.deepStrictEqual(actuals, ['1/a', '1/b']);
return testObject.$getChildren('testNodeWithIdTreeProvider', '1/a')
.then(() => testObject.$getChildren('testNodeWithIdTreeProvider', '1/b'))
.then(() => assert.fail('Should fail with duplicate id'))
.finally(done);
.catch(() => caughtExpectedError = true)
.finally(() => caughtExpectedError ? done() : assert.fail('Expected duplicate id error not thrown.'));
});
});
onDidChangeTreeNode.fire(undefined);
@@ -212,7 +214,7 @@ suite.skip('ExtHostTreeView', function () {
test('refresh root', function (done) {
target.onRefresh.event(actuals => {
assert.equal(undefined, actuals);
assert.strictEqual(undefined, actuals);
done();
});
onDidChangeTreeNode.fire(undefined);
@@ -221,8 +223,8 @@ suite.skip('ExtHostTreeView', function () {
test('refresh a parent node', () => {
return new Promise((c, e) => {
target.onRefresh.event(actuals => {
assert.deepEqual(['0/0:b'], Object.keys(actuals));
assert.deepEqual(removeUnsetKeys(actuals['0/0:b']), {
assert.deepStrictEqual(['0/0:b'], Object.keys(actuals));
assert.deepStrictEqual(removeUnsetKeys(actuals['0/0:b']), {
handle: '0/0:b',
label: { label: 'b' },
collapsibleState: TreeItemCollapsibleState.Collapsed
@@ -235,8 +237,8 @@ suite.skip('ExtHostTreeView', function () {
test('refresh a leaf node', function (done) {
target.onRefresh.event(actuals => {
assert.deepEqual(['0/0:b/0:bb'], Object.keys(actuals));
assert.deepEqual(removeUnsetKeys(actuals['0/0:b/0:bb']), {
assert.deepStrictEqual(['0/0:b/0:bb'], Object.keys(actuals));
assert.deepStrictEqual(removeUnsetKeys(actuals['0/0:b/0:bb']), {
handle: '0/0:b/0:bb',
parentHandle: '0/0:b',
label: { label: 'bb' },
@@ -262,13 +264,13 @@ suite.skip('ExtHostTreeView', function () {
test('refresh parent and child node trigger refresh only on parent - scenario 1', async () => {
return runWithEventMerging((resolve) => {
target.onRefresh.event(actuals => {
assert.deepEqual(['0/0:b', '0/0:a/0:aa'], Object.keys(actuals));
assert.deepEqual(removeUnsetKeys(actuals['0/0:b']), {
assert.deepStrictEqual(['0/0:b', '0/0:a/0:aa'], Object.keys(actuals));
assert.deepStrictEqual(removeUnsetKeys(actuals['0/0:b']), {
handle: '0/0:b',
label: { label: 'b' },
collapsibleState: TreeItemCollapsibleState.Collapsed
});
assert.deepEqual(removeUnsetKeys(actuals['0/0:a/0:aa']), {
assert.deepStrictEqual(removeUnsetKeys(actuals['0/0:a/0:aa']), {
handle: '0/0:a/0:aa',
parentHandle: '0/0:a',
label: { label: 'aa' },
@@ -285,13 +287,13 @@ suite.skip('ExtHostTreeView', function () {
test('refresh parent and child node trigger refresh only on parent - scenario 2', async () => {
return runWithEventMerging((resolve) => {
target.onRefresh.event(actuals => {
assert.deepEqual(['0/0:a/0:aa', '0/0:b'], Object.keys(actuals));
assert.deepEqual(removeUnsetKeys(actuals['0/0:b']), {
assert.deepStrictEqual(['0/0:a/0:aa', '0/0:b'], Object.keys(actuals));
assert.deepStrictEqual(removeUnsetKeys(actuals['0/0:b']), {
handle: '0/0:b',
label: { label: 'b' },
collapsibleState: TreeItemCollapsibleState.Collapsed
});
assert.deepEqual(removeUnsetKeys(actuals['0/0:a/0:aa']), {
assert.deepStrictEqual(removeUnsetKeys(actuals['0/0:a/0:aa']), {
handle: '0/0:a/0:aa',
parentHandle: '0/0:a',
label: { label: 'aa' },
@@ -308,8 +310,8 @@ suite.skip('ExtHostTreeView', function () {
test('refresh an element for label change', function (done) {
labels['a'] = 'aa';
target.onRefresh.event(actuals => {
assert.deepEqual(['0/0:a'], Object.keys(actuals));
assert.deepEqual(removeUnsetKeys(actuals['0/0:a']), {
assert.deepStrictEqual(['0/0:a'], Object.keys(actuals));
assert.deepStrictEqual(removeUnsetKeys(actuals['0/0:a']), {
handle: '0/0:aa',
label: { label: 'aa' },
collapsibleState: TreeItemCollapsibleState.Collapsed
@@ -322,7 +324,7 @@ suite.skip('ExtHostTreeView', function () {
test('refresh calls are throttled on roots', () => {
return runWithEventMerging((resolve) => {
target.onRefresh.event(actuals => {
assert.equal(undefined, actuals);
assert.strictEqual(undefined, actuals);
resolve();
});
onDidChangeTreeNode.fire(undefined);
@@ -335,7 +337,7 @@ suite.skip('ExtHostTreeView', function () {
test('refresh calls are throttled on elements', () => {
return runWithEventMerging((resolve) => {
target.onRefresh.event(actuals => {
assert.deepEqual(['0/0:a', '0/0:b'], Object.keys(actuals));
assert.deepStrictEqual(['0/0:a', '0/0:b'], Object.keys(actuals));
resolve();
});
@@ -349,7 +351,7 @@ suite.skip('ExtHostTreeView', function () {
test('refresh calls are throttled on unknown elements', () => {
return runWithEventMerging((resolve) => {
target.onRefresh.event(actuals => {
assert.deepEqual(['0/0:a', '0/0:b'], Object.keys(actuals));
assert.deepStrictEqual(['0/0:a', '0/0:b'], Object.keys(actuals));
resolve();
});
@@ -363,7 +365,7 @@ suite.skip('ExtHostTreeView', function () {
test('refresh calls are throttled on unknown elements and root', () => {
return runWithEventMerging((resolve) => {
target.onRefresh.event(actuals => {
assert.equal(undefined, actuals);
assert.strictEqual(undefined, actuals);
resolve();
});
@@ -377,7 +379,7 @@ suite.skip('ExtHostTreeView', function () {
test('refresh calls are throttled on elements and root', () => {
return runWithEventMerging((resolve) => {
target.onRefresh.event(actuals => {
assert.equal(undefined, actuals);
assert.strictEqual(undefined, actuals);
resolve();
});
@@ -396,7 +398,7 @@ suite.skip('ExtHostTreeView', function () {
target.onRefresh.event(() => {
testObject.$getChildren('testNodeTreeProvider')
.then(elements => {
assert.deepEqual(elements.map(e => e.handle), ['0/0:a//0:b']);
assert.deepStrictEqual(elements.map(e => e.handle), ['0/0:a//0:b']);
done();
});
});
@@ -439,11 +441,11 @@ suite.skip('ExtHostTreeView', function () {
testObject.$getChildren('testNodeTreeProvider')
.then(elements => {
const actuals = elements.map(e => e.handle);
assert.deepEqual(actuals, ['0/0:a', '0/0:b', '0/1:a', '0/0:d', '0/1:b', '0/0:f', '0/2:a']);
assert.deepStrictEqual(actuals, ['0/0:a', '0/0:b', '0/1:a', '0/0:d', '0/1:b', '0/0:f', '0/2:a']);
return testObject.$getChildren('testNodeTreeProvider', '0/1:b')
.then(elements => {
const actuals = elements.map(e => e.handle);
assert.deepEqual(actuals, ['0/1:b/0:h', '0/1:b/1:h', '0/1:b/0:j', '0/1:b/1:j', '0/1:b/2:h']);
assert.deepStrictEqual(actuals, ['0/1:b/0:h', '0/1:b/1:h', '0/1:b/0:j', '0/1:b/1:j', '0/1:b/2:h']);
done();
});
});
@@ -460,7 +462,7 @@ suite.skip('ExtHostTreeView', function () {
target.onRefresh.event(() => {
testObject.$getChildren('testNodeTreeProvider')
.then(elements => {
assert.deepEqual(elements.map(e => e.handle), ['0/0:c']);
assert.deepStrictEqual(elements.map(e => e.handle), ['0/0:c']);
done();
});
});
@@ -475,7 +477,7 @@ suite.skip('ExtHostTreeView', function () {
return testObject.$getChildren('testNodeTreeProvider')
.then(elements => {
assert.deepEqual(elements.map(e => e.handle), ['0/0:a', '0/0:b']);
assert.deepStrictEqual(elements.map(e => e.handle), ['0/0:a', '0/0:b']);
});
});
@@ -496,9 +498,9 @@ suite.skip('ExtHostTreeView', function () {
return treeView.reveal({ key: 'a' })
.then(() => {
assert.ok(revealTarget.calledOnce);
assert.deepEqual('treeDataProvider', revealTarget.args[0][0]);
assert.deepEqual(expected, removeUnsetKeys(revealTarget.args[0][1]));
assert.deepEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][2]);
assert.deepStrictEqual('treeDataProvider', revealTarget.args[0][0]);
assert.deepStrictEqual(expected, removeUnsetKeys(revealTarget.args[0][1]));
assert.deepStrictEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][2]);
});
});
@@ -512,10 +514,10 @@ suite.skip('ExtHostTreeView', function () {
return treeView.reveal({ key: 'aa' })
.then(() => {
assert.ok(revealTarget.calledOnce);
assert.deepEqual('treeDataProvider', revealTarget.args[0][0]);
assert.deepEqual(expected.item, removeUnsetKeys(revealTarget.args[0][1].item));
assert.deepEqual(expected.parentChain, (<Array<any>>(revealTarget.args[0][1].parentChain)).map(arg => removeUnsetKeys(arg)));
assert.deepEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][2]);
assert.deepStrictEqual('treeDataProvider', revealTarget.args[0][0]);
assert.deepStrictEqual(expected.item, removeUnsetKeys(revealTarget.args[0][1].item));
assert.deepStrictEqual(expected.parentChain, (<Array<any>>(revealTarget.args[0][1].parentChain)).map(arg => removeUnsetKeys(arg)));
assert.deepStrictEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][2]);
});
});
@@ -531,10 +533,10 @@ suite.skip('ExtHostTreeView', function () {
.then(() => treeView.reveal({ key: 'aa' })
.then(() => {
assert.ok(revealTarget.calledOnce);
assert.deepEqual('treeDataProvider', revealTarget.args[0][0]);
assert.deepEqual(expected.item, removeUnsetKeys(revealTarget.args[0][1].item));
assert.deepEqual(expected.parentChain, (<Array<any>>(revealTarget.args[0][1].parentChain)).map(arg => removeUnsetKeys(arg)));
assert.deepEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][2]);
assert.deepStrictEqual('treeDataProvider', revealTarget.args[0][0]);
assert.deepStrictEqual(expected.item, removeUnsetKeys(revealTarget.args[0][1].item));
assert.deepStrictEqual(expected.parentChain, (<Array<any>>(revealTarget.args[0][1].parentChain)).map(arg => removeUnsetKeys(arg)));
assert.deepStrictEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][2]);
}));
});
@@ -558,10 +560,10 @@ suite.skip('ExtHostTreeView', function () {
return treeView.reveal({ key: 'bac' }, { select: false, focus: false, expand: false })
.then(() => {
assert.ok(revealTarget.calledOnce);
assert.deepEqual('treeDataProvider', revealTarget.args[0][0]);
assert.deepEqual(expected.item, removeUnsetKeys(revealTarget.args[0][1].item));
assert.deepEqual(expected.parentChain, (<Array<any>>(revealTarget.args[0][1].parentChain)).map(arg => removeUnsetKeys(arg)));
assert.deepEqual({ select: false, focus: false, expand: false }, revealTarget.args[0][2]);
assert.deepStrictEqual('treeDataProvider', revealTarget.args[0][0]);
assert.deepStrictEqual(expected.item, removeUnsetKeys(revealTarget.args[0][1].item));
assert.deepStrictEqual(expected.parentChain, (<Array<any>>(revealTarget.args[0][1].parentChain)).map(arg => removeUnsetKeys(arg)));
assert.deepStrictEqual({ select: false, focus: false, expand: false }, revealTarget.args[0][2]);
});
});
@@ -589,10 +591,10 @@ suite.skip('ExtHostTreeView', function () {
return treeView.reveal({ key: 'ac' })
.then(() => {
assert.ok(revealTarget.calledOnce);
assert.deepEqual('treeDataProvider', revealTarget.args[0][0]);
assert.deepEqual(expected.item, removeUnsetKeys(revealTarget.args[0][1].item));
assert.deepEqual(expected.parentChain, (<Array<any>>(revealTarget.args[0][1].parentChain)).map(arg => removeUnsetKeys(arg)));
assert.deepEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][2]);
assert.deepStrictEqual('treeDataProvider', revealTarget.args[0][0]);
assert.deepStrictEqual(expected.item, removeUnsetKeys(revealTarget.args[0][1].item));
assert.deepStrictEqual(expected.parentChain, (<Array<any>>(revealTarget.args[0][1].parentChain)).map(arg => removeUnsetKeys(arg)));
assert.deepStrictEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][2]);
});
});
});
@@ -630,10 +632,10 @@ suite.skip('ExtHostTreeView', function () {
return treeView.reveal({ key: 'bc' })
.then(() => {
assert.ok(revealTarget.calledOnce);
assert.deepEqual('treeDataProvider', revealTarget.args[0][0]);
assert.deepEqual({ handle: '0/0:b/0:bc', label: { label: 'bc' }, collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:b' }, removeUnsetKeys(revealTarget.args[0][1]));
assert.deepEqual([{ handle: '0/0:b', label: { label: 'b' }, collapsibleState: TreeItemCollapsibleState.Collapsed }], (<Array<any>>revealTarget.args[0][2]).map(arg => removeUnsetKeys(arg)));
assert.deepEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][3]);
assert.deepStrictEqual('treeDataProvider', revealTarget.args[0][0]);
assert.deepStrictEqual({ handle: '0/0:b/0:bc', label: { label: 'bc' }, collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:b' }, removeUnsetKeys(revealTarget.args[0][1]));
assert.deepStrictEqual([{ handle: '0/0:b', label: { label: 'b' }, collapsibleState: TreeItemCollapsibleState.Collapsed }], (<Array<any>>revealTarget.args[0][2]).map(arg => removeUnsetKeys(arg)));
assert.deepStrictEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][3]);
});
});
});

View File

@@ -25,45 +25,45 @@ suite('ExtHostTypeConverter', function () {
test('MarkdownConvert - uris', function () {
let data = MarkdownString.from('Hello');
assert.equal(isEmptyObject(data.uris), true);
assert.equal(data.value, 'Hello');
assert.strictEqual(isEmptyObject(data.uris), true);
assert.strictEqual(data.value, 'Hello');
data = MarkdownString.from('Hello [link](foo)');
assert.equal(data.value, 'Hello [link](foo)');
assert.equal(isEmptyObject(data.uris), true); // no scheme, no uri
assert.strictEqual(data.value, 'Hello [link](foo)');
assert.strictEqual(isEmptyObject(data.uris), true); // no scheme, no uri
data = MarkdownString.from('Hello [link](www.noscheme.bad)');
assert.equal(data.value, 'Hello [link](www.noscheme.bad)');
assert.equal(isEmptyObject(data.uris), true); // no scheme, no uri
assert.strictEqual(data.value, 'Hello [link](www.noscheme.bad)');
assert.strictEqual(isEmptyObject(data.uris), true); // no scheme, no uri
data = MarkdownString.from('Hello [link](foo:path)');
assert.equal(data.value, 'Hello [link](foo:path)');
assert.equal(size(data.uris!), 1);
assert.strictEqual(data.value, 'Hello [link](foo:path)');
assert.strictEqual(size(data.uris!), 1);
assert.ok(!!data.uris!['foo:path']);
data = MarkdownString.from('hello@foo.bar');
assert.equal(data.value, 'hello@foo.bar');
assert.equal(size(data.uris!), 1);
assert.strictEqual(data.value, 'hello@foo.bar');
assert.strictEqual(size(data.uris!), 1);
// assert.ok(!!data.uris!['mailto:hello@foo.bar']);
data = MarkdownString.from('*hello* [click](command:me)');
assert.equal(data.value, '*hello* [click](command:me)');
assert.equal(size(data.uris!), 1);
assert.strictEqual(data.value, '*hello* [click](command:me)');
assert.strictEqual(size(data.uris!), 1);
assert.ok(!!data.uris!['command:me']);
data = MarkdownString.from('*hello* [click](file:///somepath/here). [click](file:///somepath/here)');
assert.equal(data.value, '*hello* [click](file:///somepath/here). [click](file:///somepath/here)');
assert.equal(size(data.uris!), 1);
assert.strictEqual(data.value, '*hello* [click](file:///somepath/here). [click](file:///somepath/here)');
assert.strictEqual(size(data.uris!), 1);
assert.ok(!!data.uris!['file:///somepath/here']);
data = MarkdownString.from('*hello* [click](file:///somepath/here). [click](file:///somepath/here)');
assert.equal(data.value, '*hello* [click](file:///somepath/here). [click](file:///somepath/here)');
assert.equal(size(data.uris!), 1);
assert.strictEqual(data.value, '*hello* [click](file:///somepath/here). [click](file:///somepath/here)');
assert.strictEqual(size(data.uris!), 1);
assert.ok(!!data.uris!['file:///somepath/here']);
data = MarkdownString.from('*hello* [click](file:///somepath/here). [click](file:///somepath/here2)');
assert.equal(data.value, '*hello* [click](file:///somepath/here). [click](file:///somepath/here2)');
assert.equal(size(data.uris!), 2);
assert.strictEqual(data.value, '*hello* [click](file:///somepath/here). [click](file:///somepath/here2)');
assert.strictEqual(size(data.uris!), 2);
assert.ok(!!data.uris!['file:///somepath/here']);
assert.ok(!!data.uris!['file:///somepath/here2']);
});
@@ -72,12 +72,12 @@ suite('ExtHostTypeConverter', function () {
let data = MarkdownString.from('*hello* [click](command:npm.runScriptFromHover?%7B%22documentUri%22%3A%7B%22%24mid%22%3A1%2C%22external%22%3A%22file%3A%2F%2F%2Fc%253A%2Ffoo%2Fbaz.ex%22%2C%22path%22%3A%22%2Fc%3A%2Ffoo%2Fbaz.ex%22%2C%22scheme%22%3A%22file%22%7D%2C%22script%22%3A%22dev%22%7D)');
// assert that both uri get extracted but that the latter is only decoded once...
assert.equal(size(data.uris!), 2);
assert.strictEqual(size(data.uris!), 2);
forEach(data.uris!, entry => {
if (entry.value.scheme === 'file') {
assert.ok(URI.revive(entry.value).toString().indexOf('file:///c%3A') === 0);
} else {
assert.equal(entry.value.scheme, 'command');
assert.strictEqual(entry.value.scheme, 'command');
}
});
});

View File

@@ -12,7 +12,7 @@ import { assertType } from 'vs/base/common/types';
function assertToJSON(a: any, expected: any) {
const raw = JSON.stringify(a);
const actual = JSON.parse(raw);
assert.deepEqual(actual, expected);
assert.deepStrictEqual(actual, expected);
}
suite('ExtHostTypes', function () {
@@ -20,14 +20,14 @@ suite('ExtHostTypes', function () {
test('URI, toJSON', function () {
let uri = URI.parse('file:///path/test.file');
assert.deepEqual(uri.toJSON(), {
assert.deepStrictEqual(uri.toJSON(), {
$mid: 1,
scheme: 'file',
path: '/path/test.file'
});
assert.ok(uri.fsPath);
assert.deepEqual(uri.toJSON(), {
assert.deepStrictEqual(uri.toJSON(), {
$mid: 1,
scheme: 'file',
path: '/path/test.file',
@@ -36,7 +36,7 @@ suite('ExtHostTypes', function () {
});
assert.ok(uri.toString());
assert.deepEqual(uri.toJSON(), {
assert.deepStrictEqual(uri.toJSON(), {
$mid: 1,
scheme: 'file',
path: '/path/test.file',
@@ -54,13 +54,13 @@ suite('ExtHostTypes', function () {
return 12;
});
d.dispose();
assert.equal(count, 1);
assert.strictEqual(count, 1);
d.dispose();
assert.equal(count, 1);
assert.strictEqual(count, 1);
types.Disposable.from(undefined!, { dispose() { count += 1; } }).dispose();
assert.equal(count, 2);
assert.strictEqual(count, 2);
assert.throws(() => {
@@ -83,8 +83,8 @@ suite('ExtHostTypes', function () {
assert.throws(() => (pos as any).line = 12);
let { line, character } = pos.toJSON();
assert.equal(line, 0);
assert.equal(character, 0);
assert.strictEqual(line, 0);
assert.strictEqual(character, 0);
});
test('Position, toJSON', function () {
@@ -120,11 +120,11 @@ suite('ExtHostTypes', function () {
let p2 = new types.Position(1, 2);
let p3 = new types.Position(0, 4);
assert.equal(p1.compareTo(p1), 0);
assert.equal(p2.compareTo(p1), -1);
assert.equal(p1.compareTo(p2), 1);
assert.equal(p2.compareTo(p3), 1);
assert.equal(p1.compareTo(p3), 1);
assert.strictEqual(p1.compareTo(p1), 0);
assert.strictEqual(p2.compareTo(p1), -1);
assert.strictEqual(p1.compareTo(p2), 1);
assert.strictEqual(p2.compareTo(p3), 1);
assert.strictEqual(p1.compareTo(p3), 1);
});
test('Position, translate', function () {
@@ -138,24 +138,24 @@ suite('ExtHostTypes', function () {
assert.ok(p1.translate(undefined) === p1);
let res = p1.translate(-1);
assert.equal(res.line, 0);
assert.equal(res.character, 3);
assert.strictEqual(res.line, 0);
assert.strictEqual(res.character, 3);
res = p1.translate({ lineDelta: -1 });
assert.equal(res.line, 0);
assert.equal(res.character, 3);
assert.strictEqual(res.line, 0);
assert.strictEqual(res.character, 3);
res = p1.translate(undefined, -1);
assert.equal(res.line, 1);
assert.equal(res.character, 2);
assert.strictEqual(res.line, 1);
assert.strictEqual(res.character, 2);
res = p1.translate({ characterDelta: -1 });
assert.equal(res.line, 1);
assert.equal(res.character, 2);
assert.strictEqual(res.line, 1);
assert.strictEqual(res.character, 2);
res = p1.translate(11);
assert.equal(res.line, 12);
assert.equal(res.character, 3);
assert.strictEqual(res.line, 12);
assert.strictEqual(res.character, 3);
assert.throws(() => p1.translate(null!));
assert.throws(() => p1.translate(null!, null!));
@@ -178,8 +178,8 @@ suite('ExtHostTypes', function () {
assert.ok(p1.with({ line: 1, character: 3 }) === p1);
let p2 = p1.with({ line: 0, character: 11 });
assert.equal(p2.line, 0);
assert.equal(p2.character, 11);
assert.strictEqual(p2.line, 0);
assert.strictEqual(p2.character, 11);
assert.throws(() => p1.with(null!));
assert.throws(() => p1.with(-9));
@@ -210,12 +210,12 @@ suite('ExtHostTypes', function () {
test('Range, sorting', function () {
// sorts start/end
let range = new types.Range(1, 0, 0, 0);
assert.equal(range.start.line, 0);
assert.equal(range.end.line, 1);
assert.strictEqual(range.start.line, 0);
assert.strictEqual(range.end.line, 1);
range = new types.Range(0, 0, 1, 0);
assert.equal(range.start.line, 0);
assert.equal(range.end.line, 1);
assert.strictEqual(range.start.line, 0);
assert.strictEqual(range.end.line, 1);
});
test('Range, isEmpty|isSingleLine', function () {
@@ -254,26 +254,26 @@ suite('ExtHostTypes', function () {
let res: types.Range;
res = range.intersection(range)!;
assert.equal(res.start.line, 1);
assert.equal(res.start.character, 1);
assert.equal(res.end.line, 2);
assert.equal(res.end.character, 11);
assert.strictEqual(res.start.line, 1);
assert.strictEqual(res.start.character, 1);
assert.strictEqual(res.end.line, 2);
assert.strictEqual(res.end.character, 11);
res = range.intersection(new types.Range(2, 12, 4, 0))!;
assert.equal(res, undefined);
assert.strictEqual(res, undefined);
res = range.intersection(new types.Range(0, 0, 1, 0))!;
assert.equal(res, undefined);
assert.strictEqual(res, undefined);
res = range.intersection(new types.Range(0, 0, 1, 1))!;
assert.ok(res.isEmpty);
assert.equal(res.start.line, 1);
assert.equal(res.start.character, 1);
assert.strictEqual(res.start.line, 1);
assert.strictEqual(res.start.character, 1);
res = range.intersection(new types.Range(2, 11, 61, 1))!;
assert.ok(res.isEmpty);
assert.equal(res.start.line, 2);
assert.equal(res.start.character, 11);
assert.strictEqual(res.start.line, 2);
assert.strictEqual(res.start.character, 11);
assert.throws(() => range.intersection(null!));
assert.throws(() => range.intersection(undefined!));
@@ -286,14 +286,14 @@ suite('ExtHostTypes', function () {
let res: types.Range;
res = ran1.union(new types.Range(2, 2, 9, 9));
assert.ok(res.start === ran1.start);
assert.equal(res.end.line, 9);
assert.equal(res.end.character, 9);
assert.strictEqual(res.end.line, 9);
assert.strictEqual(res.end.character, 9);
ran1 = new types.Range(2, 1, 5, 3);
res = ran1.union(new types.Range(1, 0, 4, 2));
assert.ok(res.end === ran1.end);
assert.equal(res.start.line, 1);
assert.equal(res.start.character, 0);
assert.strictEqual(res.start.line, 1);
assert.strictEqual(res.start.character, 0);
});
test('Range, with', function () {
@@ -311,22 +311,22 @@ suite('ExtHostTypes', function () {
assert.ok(range.with({ end: new types.Position(2, 11) }) === range);
let res = range.with(undefined, new types.Position(9, 8));
assert.equal(res.end.line, 9);
assert.equal(res.end.character, 8);
assert.equal(res.start.line, 1);
assert.equal(res.start.character, 1);
assert.strictEqual(res.end.line, 9);
assert.strictEqual(res.end.character, 8);
assert.strictEqual(res.start.line, 1);
assert.strictEqual(res.start.character, 1);
res = range.with({ end: new types.Position(9, 8) });
assert.equal(res.end.line, 9);
assert.equal(res.end.character, 8);
assert.equal(res.start.line, 1);
assert.equal(res.start.character, 1);
assert.strictEqual(res.end.line, 9);
assert.strictEqual(res.end.character, 8);
assert.strictEqual(res.start.line, 1);
assert.strictEqual(res.start.character, 1);
res = range.with({ end: new types.Position(9, 8), start: new types.Position(2, 3) });
assert.equal(res.end.line, 9);
assert.equal(res.end.character, 8);
assert.equal(res.start.line, 2);
assert.equal(res.start.character, 3);
assert.strictEqual(res.end.line, 9);
assert.strictEqual(res.end.character, 8);
assert.strictEqual(res.start.line, 2);
assert.strictEqual(res.start.character, 3);
assert.throws(() => range.with(null!));
assert.throws(() => range.with(undefined, null!));
@@ -336,14 +336,14 @@ suite('ExtHostTypes', function () {
let range = new types.Range(1, 1, 2, 11);
let edit = new types.TextEdit(range, undefined!);
assert.equal(edit.newText, '');
assert.strictEqual(edit.newText, '');
assertToJSON(edit, { range: [{ line: 1, character: 1 }, { line: 2, character: 11 }], newText: '' });
edit = new types.TextEdit(range, null!);
assert.equal(edit.newText, '');
assert.strictEqual(edit.newText, '');
edit = new types.TextEdit(range, '');
assert.equal(edit.newText, '');
assert.strictEqual(edit.newText, '');
});
test('WorkspaceEdit', () => {
@@ -356,13 +356,13 @@ suite('ExtHostTypes', function () {
edit.set(a, [types.TextEdit.insert(new types.Position(0, 0), 'fff')]);
assert.ok(edit.has(a));
assert.equal(edit.size, 1);
assert.strictEqual(edit.size, 1);
assertToJSON(edit, [[a.toJSON(), [{ range: [{ line: 0, character: 0 }, { line: 0, character: 0 }], newText: 'fff' }]]]);
edit.insert(b, new types.Position(1, 1), 'fff');
edit.delete(b, new types.Range(0, 0, 0, 0));
assert.ok(edit.has(b));
assert.equal(edit.size, 2);
assert.strictEqual(edit.size, 2);
assertToJSON(edit, [
[a.toJSON(), [{ range: [{ line: 0, character: 0 }, { line: 0, character: 0 }], newText: 'fff' }]],
[b.toJSON(), [{ range: [{ line: 1, character: 1 }, { line: 1, character: 1 }], newText: 'fff' }, { range: [{ line: 0, character: 0 }, { line: 0, character: 0 }], newText: '' }]]
@@ -370,10 +370,10 @@ suite('ExtHostTypes', function () {
edit.set(b, undefined!);
assert.ok(!edit.has(b));
assert.equal(edit.size, 1);
assert.strictEqual(edit.size, 1);
edit.set(b, [types.TextEdit.insert(new types.Position(0, 0), 'ffff')]);
assert.equal(edit.get(b).length, 1);
assert.strictEqual(edit.get(b).length, 1);
});
test('WorkspaceEdit - keep order of text and file changes', function () {
@@ -385,21 +385,21 @@ suite('ExtHostTypes', function () {
edit.replace(URI.parse('foo:b'), new types.Range(3, 1, 3, 1), 'bazz');
const all = edit._allEntries();
assert.equal(all.length, 4);
assert.strictEqual(all.length, 4);
const [first, second, third, fourth] = all;
assertType(first._type === types.FileEditType.Text);
assert.equal(first.uri.toString(), 'foo:a');
assert.strictEqual(first.uri.toString(), 'foo:a');
assertType(second._type === types.FileEditType.File);
assert.equal(second.from!.toString(), 'foo:a');
assert.equal(second.to!.toString(), 'foo:b');
assert.strictEqual(second.from!.toString(), 'foo:a');
assert.strictEqual(second.to!.toString(), 'foo:b');
assertType(third._type === types.FileEditType.Text);
assert.equal(third.uri.toString(), 'foo:a');
assert.strictEqual(third.uri.toString(), 'foo:a');
assertType(fourth._type === types.FileEditType.Text);
assert.equal(fourth.uri.toString(), 'foo:b');
assert.strictEqual(fourth.uri.toString(), 'foo:b');
});
test('WorkspaceEdit - two edits for one resource', function () {
@@ -408,13 +408,13 @@ suite('ExtHostTypes', function () {
edit.insert(uri, new types.Position(0, 0), 'Hello');
edit.insert(uri, new types.Position(0, 0), 'Foo');
assert.equal(edit._allEntries().length, 2);
assert.strictEqual(edit._allEntries().length, 2);
let [first, second] = edit._allEntries();
assertType(first._type === types.FileEditType.Text);
assertType(second._type === types.FileEditType.Text);
assert.equal(first.edit.newText, 'Hello');
assert.equal(second.edit.newText, 'Foo');
assert.strictEqual(first.edit.newText, 'Hello');
assert.strictEqual(second.edit.newText, 'Foo');
});
test('DocumentLink', () => {
@@ -463,7 +463,7 @@ suite('ExtHostTypes', function () {
let info = new types.SymbolInformation('foo', types.SymbolKind.Array, new types.Range(1, 1, 2, 3));
assert.ok(info.location instanceof types.Location);
assert.equal(info.location.uri, undefined);
assert.strictEqual(info.location.uri, undefined);
});
test('SnippetString, builder-methods', function () {
@@ -471,78 +471,78 @@ suite('ExtHostTypes', function () {
let string: types.SnippetString;
string = new types.SnippetString();
assert.equal(string.appendText('I need $ and $').value, 'I need \\$ and \\$');
assert.strictEqual(string.appendText('I need $ and $').value, 'I need \\$ and \\$');
string = new types.SnippetString();
assert.equal(string.appendText('I need \\$').value, 'I need \\\\\\$');
assert.strictEqual(string.appendText('I need \\$').value, 'I need \\\\\\$');
string = new types.SnippetString();
string.appendPlaceholder('fo$o}');
assert.equal(string.value, '${1:fo\\$o\\}}');
assert.strictEqual(string.value, '${1:fo\\$o\\}}');
string = new types.SnippetString();
string.appendText('foo').appendTabstop(0).appendText('bar');
assert.equal(string.value, 'foo$0bar');
assert.strictEqual(string.value, 'foo$0bar');
string = new types.SnippetString();
string.appendText('foo').appendTabstop().appendText('bar');
assert.equal(string.value, 'foo$1bar');
assert.strictEqual(string.value, 'foo$1bar');
string = new types.SnippetString();
string.appendText('foo').appendTabstop(42).appendText('bar');
assert.equal(string.value, 'foo$42bar');
assert.strictEqual(string.value, 'foo$42bar');
string = new types.SnippetString();
string.appendText('foo').appendPlaceholder('farboo').appendText('bar');
assert.equal(string.value, 'foo${1:farboo}bar');
assert.strictEqual(string.value, 'foo${1:farboo}bar');
string = new types.SnippetString();
string.appendText('foo').appendPlaceholder('far$boo').appendText('bar');
assert.equal(string.value, 'foo${1:far\\$boo}bar');
assert.strictEqual(string.value, 'foo${1:far\\$boo}bar');
string = new types.SnippetString();
string.appendText('foo').appendPlaceholder(b => b.appendText('abc').appendPlaceholder('nested')).appendText('bar');
assert.equal(string.value, 'foo${1:abc${2:nested}}bar');
assert.strictEqual(string.value, 'foo${1:abc${2:nested}}bar');
string = new types.SnippetString();
string.appendVariable('foo');
assert.equal(string.value, '${foo}');
assert.strictEqual(string.value, '${foo}');
string = new types.SnippetString();
string.appendText('foo').appendVariable('TM_SELECTED_TEXT').appendText('bar');
assert.equal(string.value, 'foo${TM_SELECTED_TEXT}bar');
assert.strictEqual(string.value, 'foo${TM_SELECTED_TEXT}bar');
string = new types.SnippetString();
string.appendVariable('BAR', b => b.appendPlaceholder('ops'));
assert.equal(string.value, '${BAR:${1:ops}}');
assert.strictEqual(string.value, '${BAR:${1:ops}}');
string = new types.SnippetString();
string.appendVariable('BAR', b => { });
assert.equal(string.value, '${BAR}');
assert.strictEqual(string.value, '${BAR}');
string = new types.SnippetString();
string.appendChoice(['b', 'a', 'r']);
assert.equal(string.value, '${1|b,a,r|}');
assert.strictEqual(string.value, '${1|b,a,r|}');
string = new types.SnippetString();
string.appendChoice(['b,1', 'a,2', 'r,3']);
assert.equal(string.value, '${1|b\\,1,a\\,2,r\\,3|}');
assert.strictEqual(string.value, '${1|b\\,1,a\\,2,r\\,3|}');
string = new types.SnippetString();
string.appendChoice(['b', 'a', 'r'], 0);
assert.equal(string.value, '${0|b,a,r|}');
assert.strictEqual(string.value, '${0|b,a,r|}');
string = new types.SnippetString();
string.appendText('foo').appendChoice(['far', 'boo']).appendText('bar');
assert.equal(string.value, 'foo${1|far,boo|}bar');
assert.strictEqual(string.value, 'foo${1|far,boo|}bar');
string = new types.SnippetString();
string.appendText('foo').appendChoice(['far', '$boo']).appendText('bar');
assert.equal(string.value, 'foo${1|far,\\$boo|}bar');
assert.strictEqual(string.value, 'foo${1|far,\\$boo|}bar');
string = new types.SnippetString();
string.appendText('foo').appendPlaceholder('farboo').appendChoice(['far', 'boo']).appendText('bar');
assert.equal(string.value, 'foo${1:farboo}${2|far,boo|}bar');
assert.strictEqual(string.value, 'foo${1:farboo}${2|far,boo|}bar');
});
test('instanceof doesn\'t work for FileSystemError #49386', function () {
@@ -584,7 +584,7 @@ suite('ExtHostTypes', function () {
builder.push(1, 0, 5, 1, 1);
builder.push(1, 10, 4, 2, 2);
builder.push(2, 2, 3, 2, 2);
assert.deepEqual(toArr(builder.build().data), [
assert.deepStrictEqual(toArr(builder.build().data), [
1, 0, 5, 1, 1,
0, 10, 4, 2, 2,
1, 2, 3, 2, 2
@@ -596,7 +596,7 @@ suite('ExtHostTypes', function () {
builder.push(1, 0, 5, 1);
builder.push(1, 10, 4, 2);
builder.push(2, 2, 3, 2);
assert.deepEqual(toArr(builder.build().data), [
assert.deepStrictEqual(toArr(builder.build().data), [
1, 0, 5, 1, 0,
0, 10, 4, 2, 0,
1, 2, 3, 2, 0
@@ -609,7 +609,7 @@ suite('ExtHostTypes', function () {
builder.push(2, 10, 1, 2, 2);
builder.push(2, 15, 2, 3, 3);
builder.push(1, 0, 4, 4, 4);
assert.deepEqual(toArr(builder.build().data), [
assert.deepStrictEqual(toArr(builder.build().data), [
1, 0, 4, 4, 4,
1, 0, 5, 1, 1,
0, 10, 1, 2, 2,
@@ -621,7 +621,7 @@ suite('ExtHostTypes', function () {
const builder = new types.SemanticTokensBuilder();
builder.push(2, 10, 5, 1, 1);
builder.push(2, 2, 4, 2, 2);
assert.deepEqual(toArr(builder.build().data), [
assert.deepStrictEqual(toArr(builder.build().data), [
2, 2, 4, 2, 2,
0, 8, 5, 1, 1
]);
@@ -636,7 +636,7 @@ suite('ExtHostTypes', function () {
builder.push(new types.Range(1, 0, 1, 5), 'bType');
builder.push(new types.Range(2, 0, 2, 4), 'cType', ['mod0', 'mod5']);
builder.push(new types.Range(3, 0, 3, 3), 'dType', ['mod2', 'mod4']);
assert.deepEqual(toArr(builder.build().data), [
assert.deepStrictEqual(toArr(builder.build().data), [
1, 0, 5, 1, 0,
1, 0, 4, 2, 1 | (1 << 5),
1, 0, 3, 3, (1 << 2) | (1 << 4)
@@ -645,7 +645,7 @@ suite('ExtHostTypes', function () {
test('Markdown codeblock rendering is swapped #111604', function () {
const md = new types.MarkdownString().appendCodeblock('<img src=0 onerror="alert(1)">', 'html');
assert.deepEqual(md.value, '\n```html\n<img src=0 onerror="alert(1)">\n```\n');
assert.deepStrictEqual(md.value, '\n```html\n<img src=0 onerror="alert(1)">\n```\n');
});
});

View File

@@ -52,7 +52,7 @@ suite('ExtHostWorkspace', function () {
function assertAsRelativePath(workspace: ExtHostWorkspace, input: string, expected: string, includeWorkspace?: boolean) {
const actual = workspace.getRelativePath(input, includeWorkspace);
assert.equal(actual, expected);
assert.strictEqual(actual, expected);
}
test('asRelativePath', () => {
@@ -116,19 +116,19 @@ suite('ExtHostWorkspace', function () {
test('getPath, legacy', function () {
let ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService());
assert.equal(ws.getPath(), undefined);
assert.strictEqual(ws.getPath(), undefined);
ws = createExtHostWorkspace(new TestRPCProtocol(), null!, new NullLogService());
assert.equal(ws.getPath(), undefined);
assert.strictEqual(ws.getPath(), undefined);
ws = createExtHostWorkspace(new TestRPCProtocol(), undefined!, new NullLogService());
assert.equal(ws.getPath(), undefined);
assert.strictEqual(ws.getPath(), undefined);
ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.file('Folder'), 0), aWorkspaceFolderData(URI.file('Another/Folder'), 1)] }, new NullLogService());
assert.equal(ws.getPath()!.replace(/\\/g, '/'), '/Folder');
assert.strictEqual(ws.getPath()!.replace(/\\/g, '/'), '/Folder');
ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.file('/Folder'), 0)] }, new NullLogService());
assert.equal(ws.getPath()!.replace(/\\/g, '/'), '/Folder');
assert.strictEqual(ws.getPath()!.replace(/\\/g, '/'), '/Folder');
});
test('WorkspaceFolder has name and index', function () {
@@ -136,10 +136,10 @@ suite('ExtHostWorkspace', function () {
const [one, two] = ws.getWorkspaceFolders()!;
assert.equal(one.name, 'One');
assert.equal(one.index, 0);
assert.equal(two.name, 'Two');
assert.equal(two.index, 1);
assert.strictEqual(one.name, 'One');
assert.strictEqual(one.index, 0);
assert.strictEqual(two.name, 'Two');
assert.strictEqual(two.index, 1);
});
test('getContainingWorkspaceFolder', () => {
@@ -154,40 +154,40 @@ suite('ExtHostWorkspace', function () {
}, new NullLogService());
let folder = ws.getWorkspaceFolder(URI.file('/foo/bar'));
assert.equal(folder, undefined);
assert.strictEqual(folder, undefined);
folder = ws.getWorkspaceFolder(URI.file('/Coding/One/file/path.txt'))!;
assert.equal(folder.name, 'One');
assert.strictEqual(folder.name, 'One');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/file/path.txt'))!;
assert.equal(folder.name, 'Two');
assert.strictEqual(folder.name, 'Two');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nest'))!;
assert.equal(folder.name, 'Two');
assert.strictEqual(folder.name, 'Two');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested/file'))!;
assert.equal(folder.name, 'Nested');
assert.strictEqual(folder.name, 'Nested');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested/f'))!;
assert.equal(folder.name, 'Nested');
assert.strictEqual(folder.name, 'Nested');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested'), true)!;
assert.equal(folder.name, 'Two');
assert.strictEqual(folder.name, 'Two');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested/'), true)!;
assert.equal(folder.name, 'Two');
assert.strictEqual(folder.name, 'Two');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested'))!;
assert.equal(folder.name, 'Nested');
assert.strictEqual(folder.name, 'Nested');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two/Nested/'))!;
assert.equal(folder.name, 'Nested');
assert.strictEqual(folder.name, 'Nested');
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two'), true)!;
assert.equal(folder, undefined);
assert.strictEqual(folder, undefined);
folder = ws.getWorkspaceFolder(URI.file('/Coding/Two'), false)!;
assert.equal(folder.name, 'Two');
assert.strictEqual(folder.name, 'Two');
});
test('Multiroot change event should have a delta, #29641', function (done) {
@@ -203,8 +203,8 @@ suite('ExtHostWorkspace', function () {
let sub = ws.onDidChangeWorkspace(e => {
try {
assert.deepEqual(e.added, []);
assert.deepEqual(e.removed, []);
assert.deepStrictEqual(e.added, []);
assert.deepStrictEqual(e.removed, []);
} catch (error) {
finish(error);
}
@@ -214,9 +214,9 @@ suite('ExtHostWorkspace', function () {
sub = ws.onDidChangeWorkspace(e => {
try {
assert.deepEqual(e.removed, []);
assert.equal(e.added.length, 1);
assert.equal(e.added[0].uri.toString(), 'foo:bar');
assert.deepStrictEqual(e.removed, []);
assert.strictEqual(e.added.length, 1);
assert.strictEqual(e.added[0].uri.toString(), 'foo:bar');
} catch (error) {
finish(error);
}
@@ -226,9 +226,9 @@ suite('ExtHostWorkspace', function () {
sub = ws.onDidChangeWorkspace(e => {
try {
assert.deepEqual(e.removed, []);
assert.equal(e.added.length, 1);
assert.equal(e.added[0].uri.toString(), 'foo:bar2');
assert.deepStrictEqual(e.removed, []);
assert.strictEqual(e.added.length, 1);
assert.strictEqual(e.added[0].uri.toString(), 'foo:bar2');
} catch (error) {
finish(error);
}
@@ -238,12 +238,12 @@ suite('ExtHostWorkspace', function () {
sub = ws.onDidChangeWorkspace(e => {
try {
assert.equal(e.removed.length, 2);
assert.equal(e.removed[0].uri.toString(), 'foo:bar');
assert.equal(e.removed[1].uri.toString(), 'foo:bar2');
assert.strictEqual(e.removed.length, 2);
assert.strictEqual(e.removed[0].uri.toString(), 'foo:bar');
assert.strictEqual(e.removed[1].uri.toString(), 'foo:bar2');
assert.equal(e.added.length, 1);
assert.equal(e.added[0].uri.toString(), 'foo:bar3');
assert.strictEqual(e.added.length, 1);
assert.strictEqual(e.added[0].uri.toString(), 'foo:bar3');
} catch (error) {
finish(error);
}
@@ -259,13 +259,13 @@ suite('ExtHostWorkspace', function () {
let firstFolder = ws.getWorkspaceFolders()![0];
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar2'), 0), aWorkspaceFolderData(URI.parse('foo:bar'), 1, 'renamed')] });
assert.equal(ws.getWorkspaceFolders()![1], firstFolder);
assert.equal(firstFolder.index, 1);
assert.equal(firstFolder.name, 'renamed');
assert.strictEqual(ws.getWorkspaceFolders()![1], firstFolder);
assert.strictEqual(firstFolder.index, 1);
assert.strictEqual(firstFolder.name, 'renamed');
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar3'), 0), aWorkspaceFolderData(URI.parse('foo:bar2'), 1), aWorkspaceFolderData(URI.parse('foo:bar'), 2)] });
assert.equal(ws.getWorkspaceFolders()![2], firstFolder);
assert.equal(firstFolder.index, 2);
assert.strictEqual(ws.getWorkspaceFolders()![2], firstFolder);
assert.strictEqual(firstFolder.index, 2);
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar3'), 0)] });
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar3'), 0), aWorkspaceFolderData(URI.parse('foo:bar'), 1)] });
@@ -276,18 +276,18 @@ suite('ExtHostWorkspace', function () {
test('updateWorkspaceFolders - invalid arguments', function () {
let ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [] }, new NullLogService());
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, null!, null!));
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 0, 0));
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 0, 1));
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 1, 0));
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, -1, 0));
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, -1, -1));
assert.strictEqual(false, ws.updateWorkspaceFolders(extensionDescriptor, null!, null!));
assert.strictEqual(false, ws.updateWorkspaceFolders(extensionDescriptor, 0, 0));
assert.strictEqual(false, ws.updateWorkspaceFolders(extensionDescriptor, 0, 1));
assert.strictEqual(false, ws.updateWorkspaceFolders(extensionDescriptor, 1, 0));
assert.strictEqual(false, ws.updateWorkspaceFolders(extensionDescriptor, -1, 0));
assert.strictEqual(false, ws.updateWorkspaceFolders(extensionDescriptor, -1, -1));
ws = createExtHostWorkspace(new TestRPCProtocol(), { id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar'), 0)] }, new NullLogService());
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 1, 1));
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 0, 2));
assert.equal(false, ws.updateWorkspaceFolders(extensionDescriptor, 0, 1, asUpdateWorkspaceFolderData(URI.parse('foo:bar'))));
assert.strictEqual(false, ws.updateWorkspaceFolders(extensionDescriptor, 1, 1));
assert.strictEqual(false, ws.updateWorkspaceFolders(extensionDescriptor, 0, 2));
assert.strictEqual(false, ws.updateWorkspaceFolders(extensionDescriptor, 0, 1, asUpdateWorkspaceFolderData(URI.parse('foo:bar'))));
});
test('updateWorkspaceFolders - valid arguments', function (done) {
@@ -312,38 +312,38 @@ suite('ExtHostWorkspace', function () {
// Add one folder
//
assert.equal(true, ws.updateWorkspaceFolders(extensionDescriptor, 0, 0, asUpdateWorkspaceFolderData(URI.parse('foo:bar'))));
assert.equal(1, ws.workspace!.folders.length);
assert.equal(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar').toString());
assert.strictEqual(true, ws.updateWorkspaceFolders(extensionDescriptor, 0, 0, asUpdateWorkspaceFolderData(URI.parse('foo:bar'))));
assert.strictEqual(1, ws.workspace!.folders.length);
assert.strictEqual(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar').toString());
const firstAddedFolder = ws.getWorkspaceFolders()![0];
let gotEvent = false;
let sub = ws.onDidChangeWorkspace(e => {
try {
assert.deepEqual(e.removed, []);
assert.equal(e.added.length, 1);
assert.equal(e.added[0].uri.toString(), 'foo:bar');
assert.equal(e.added[0], firstAddedFolder); // verify object is still live
assert.deepStrictEqual(e.removed, []);
assert.strictEqual(e.added.length, 1);
assert.strictEqual(e.added[0].uri.toString(), 'foo:bar');
assert.strictEqual(e.added[0], firstAddedFolder); // verify object is still live
gotEvent = true;
} catch (error) {
finish(error);
}
});
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar'), 0)] }); // simulate acknowledgement from main side
assert.equal(gotEvent, true);
assert.strictEqual(gotEvent, true);
sub.dispose();
assert.equal(ws.getWorkspaceFolders()![0], firstAddedFolder); // verify object is still live
assert.strictEqual(ws.getWorkspaceFolders()![0], firstAddedFolder); // verify object is still live
//
// Add two more folders
//
assert.equal(true, ws.updateWorkspaceFolders(extensionDescriptor, 1, 0, asUpdateWorkspaceFolderData(URI.parse('foo:bar1')), asUpdateWorkspaceFolderData(URI.parse('foo:bar2'))));
assert.equal(3, ws.workspace!.folders.length);
assert.equal(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar').toString());
assert.equal(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar1').toString());
assert.equal(ws.workspace!.folders[2].uri.toString(), URI.parse('foo:bar2').toString());
assert.strictEqual(true, ws.updateWorkspaceFolders(extensionDescriptor, 1, 0, asUpdateWorkspaceFolderData(URI.parse('foo:bar1')), asUpdateWorkspaceFolderData(URI.parse('foo:bar2'))));
assert.strictEqual(3, ws.workspace!.folders.length);
assert.strictEqual(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar').toString());
assert.strictEqual(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar1').toString());
assert.strictEqual(ws.workspace!.folders[2].uri.toString(), URI.parse('foo:bar2').toString());
const secondAddedFolder = ws.getWorkspaceFolders()![1];
const thirdAddedFolder = ws.getWorkspaceFolders()![2];
@@ -351,91 +351,91 @@ suite('ExtHostWorkspace', function () {
gotEvent = false;
sub = ws.onDidChangeWorkspace(e => {
try {
assert.deepEqual(e.removed, []);
assert.equal(e.added.length, 2);
assert.equal(e.added[0].uri.toString(), 'foo:bar1');
assert.equal(e.added[1].uri.toString(), 'foo:bar2');
assert.equal(e.added[0], secondAddedFolder);
assert.equal(e.added[1], thirdAddedFolder);
assert.deepStrictEqual(e.removed, []);
assert.strictEqual(e.added.length, 2);
assert.strictEqual(e.added[0].uri.toString(), 'foo:bar1');
assert.strictEqual(e.added[1].uri.toString(), 'foo:bar2');
assert.strictEqual(e.added[0], secondAddedFolder);
assert.strictEqual(e.added[1], thirdAddedFolder);
gotEvent = true;
} catch (error) {
finish(error);
}
});
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar'), 0), aWorkspaceFolderData(URI.parse('foo:bar1'), 1), aWorkspaceFolderData(URI.parse('foo:bar2'), 2)] }); // simulate acknowledgement from main side
assert.equal(gotEvent, true);
assert.strictEqual(gotEvent, true);
sub.dispose();
assert.equal(ws.getWorkspaceFolders()![0], firstAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![1], secondAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![2], thirdAddedFolder); // verify object is still live
assert.strictEqual(ws.getWorkspaceFolders()![0], firstAddedFolder); // verify object is still live
assert.strictEqual(ws.getWorkspaceFolders()![1], secondAddedFolder); // verify object is still live
assert.strictEqual(ws.getWorkspaceFolders()![2], thirdAddedFolder); // verify object is still live
//
// Remove one folder
//
assert.equal(true, ws.updateWorkspaceFolders(extensionDescriptor, 2, 1));
assert.equal(2, ws.workspace!.folders.length);
assert.equal(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar').toString());
assert.equal(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar1').toString());
assert.strictEqual(true, ws.updateWorkspaceFolders(extensionDescriptor, 2, 1));
assert.strictEqual(2, ws.workspace!.folders.length);
assert.strictEqual(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar').toString());
assert.strictEqual(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar1').toString());
gotEvent = false;
sub = ws.onDidChangeWorkspace(e => {
try {
assert.deepEqual(e.added, []);
assert.equal(e.removed.length, 1);
assert.equal(e.removed[0], thirdAddedFolder);
assert.deepStrictEqual(e.added, []);
assert.strictEqual(e.removed.length, 1);
assert.strictEqual(e.removed[0], thirdAddedFolder);
gotEvent = true;
} catch (error) {
finish(error);
}
});
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar'), 0), aWorkspaceFolderData(URI.parse('foo:bar1'), 1)] }); // simulate acknowledgement from main side
assert.equal(gotEvent, true);
assert.strictEqual(gotEvent, true);
sub.dispose();
assert.equal(ws.getWorkspaceFolders()![0], firstAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![1], secondAddedFolder); // verify object is still live
assert.strictEqual(ws.getWorkspaceFolders()![0], firstAddedFolder); // verify object is still live
assert.strictEqual(ws.getWorkspaceFolders()![1], secondAddedFolder); // verify object is still live
//
// Rename folder
//
assert.equal(true, ws.updateWorkspaceFolders(extensionDescriptor, 0, 2, asUpdateWorkspaceFolderData(URI.parse('foo:bar'), 'renamed 1'), asUpdateWorkspaceFolderData(URI.parse('foo:bar1'), 'renamed 2')));
assert.equal(2, ws.workspace!.folders.length);
assert.equal(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar').toString());
assert.equal(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar1').toString());
assert.equal(ws.workspace!.folders[0].name, 'renamed 1');
assert.equal(ws.workspace!.folders[1].name, 'renamed 2');
assert.equal(ws.getWorkspaceFolders()![0].name, 'renamed 1');
assert.equal(ws.getWorkspaceFolders()![1].name, 'renamed 2');
assert.strictEqual(true, ws.updateWorkspaceFolders(extensionDescriptor, 0, 2, asUpdateWorkspaceFolderData(URI.parse('foo:bar'), 'renamed 1'), asUpdateWorkspaceFolderData(URI.parse('foo:bar1'), 'renamed 2')));
assert.strictEqual(2, ws.workspace!.folders.length);
assert.strictEqual(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar').toString());
assert.strictEqual(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar1').toString());
assert.strictEqual(ws.workspace!.folders[0].name, 'renamed 1');
assert.strictEqual(ws.workspace!.folders[1].name, 'renamed 2');
assert.strictEqual(ws.getWorkspaceFolders()![0].name, 'renamed 1');
assert.strictEqual(ws.getWorkspaceFolders()![1].name, 'renamed 2');
gotEvent = false;
sub = ws.onDidChangeWorkspace(e => {
try {
assert.deepEqual(e.added, []);
assert.equal(e.removed.length, []);
assert.deepStrictEqual(e.added, []);
assert.strictEqual(e.removed.length, 0);
gotEvent = true;
} catch (error) {
finish(error);
}
});
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar'), 0, 'renamed 1'), aWorkspaceFolderData(URI.parse('foo:bar1'), 1, 'renamed 2')] }); // simulate acknowledgement from main side
assert.equal(gotEvent, true);
assert.strictEqual(gotEvent, true);
sub.dispose();
assert.equal(ws.getWorkspaceFolders()![0], firstAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![1], secondAddedFolder); // verify object is still live
assert.equal(ws.workspace!.folders[0].name, 'renamed 1');
assert.equal(ws.workspace!.folders[1].name, 'renamed 2');
assert.equal(ws.getWorkspaceFolders()![0].name, 'renamed 1');
assert.equal(ws.getWorkspaceFolders()![1].name, 'renamed 2');
assert.strictEqual(ws.getWorkspaceFolders()![0], firstAddedFolder); // verify object is still live
assert.strictEqual(ws.getWorkspaceFolders()![1], secondAddedFolder); // verify object is still live
assert.strictEqual(ws.workspace!.folders[0].name, 'renamed 1');
assert.strictEqual(ws.workspace!.folders[1].name, 'renamed 2');
assert.strictEqual(ws.getWorkspaceFolders()![0].name, 'renamed 1');
assert.strictEqual(ws.getWorkspaceFolders()![1].name, 'renamed 2');
//
// Add and remove folders
//
assert.equal(true, ws.updateWorkspaceFolders(extensionDescriptor, 0, 2, asUpdateWorkspaceFolderData(URI.parse('foo:bar3')), asUpdateWorkspaceFolderData(URI.parse('foo:bar4'))));
assert.equal(2, ws.workspace!.folders.length);
assert.equal(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar3').toString());
assert.equal(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar4').toString());
assert.strictEqual(true, ws.updateWorkspaceFolders(extensionDescriptor, 0, 2, asUpdateWorkspaceFolderData(URI.parse('foo:bar3')), asUpdateWorkspaceFolderData(URI.parse('foo:bar4'))));
assert.strictEqual(2, ws.workspace!.folders.length);
assert.strictEqual(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar3').toString());
assert.strictEqual(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar4').toString());
const fourthAddedFolder = ws.getWorkspaceFolders()![0];
const fifthAddedFolder = ws.getWorkspaceFolders()![1];
@@ -443,71 +443,71 @@ suite('ExtHostWorkspace', function () {
gotEvent = false;
sub = ws.onDidChangeWorkspace(e => {
try {
assert.equal(e.added.length, 2);
assert.equal(e.added[0], fourthAddedFolder);
assert.equal(e.added[1], fifthAddedFolder);
assert.equal(e.removed.length, 2);
assert.equal(e.removed[0], firstAddedFolder);
assert.equal(e.removed[1], secondAddedFolder);
assert.strictEqual(e.added.length, 2);
assert.strictEqual(e.added[0], fourthAddedFolder);
assert.strictEqual(e.added[1], fifthAddedFolder);
assert.strictEqual(e.removed.length, 2);
assert.strictEqual(e.removed[0], firstAddedFolder);
assert.strictEqual(e.removed[1], secondAddedFolder);
gotEvent = true;
} catch (error) {
finish(error);
}
});
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar3'), 0), aWorkspaceFolderData(URI.parse('foo:bar4'), 1)] }); // simulate acknowledgement from main side
assert.equal(gotEvent, true);
assert.strictEqual(gotEvent, true);
sub.dispose();
assert.equal(ws.getWorkspaceFolders()![0], fourthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![1], fifthAddedFolder); // verify object is still live
assert.strictEqual(ws.getWorkspaceFolders()![0], fourthAddedFolder); // verify object is still live
assert.strictEqual(ws.getWorkspaceFolders()![1], fifthAddedFolder); // verify object is still live
//
// Swap folders
//
assert.equal(true, ws.updateWorkspaceFolders(extensionDescriptor, 0, 2, asUpdateWorkspaceFolderData(URI.parse('foo:bar4')), asUpdateWorkspaceFolderData(URI.parse('foo:bar3'))));
assert.equal(2, ws.workspace!.folders.length);
assert.equal(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar4').toString());
assert.equal(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar3').toString());
assert.strictEqual(true, ws.updateWorkspaceFolders(extensionDescriptor, 0, 2, asUpdateWorkspaceFolderData(URI.parse('foo:bar4')), asUpdateWorkspaceFolderData(URI.parse('foo:bar3'))));
assert.strictEqual(2, ws.workspace!.folders.length);
assert.strictEqual(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar4').toString());
assert.strictEqual(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar3').toString());
assert.equal(ws.getWorkspaceFolders()![0], fifthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![1], fourthAddedFolder); // verify object is still live
assert.strictEqual(ws.getWorkspaceFolders()![0], fifthAddedFolder); // verify object is still live
assert.strictEqual(ws.getWorkspaceFolders()![1], fourthAddedFolder); // verify object is still live
gotEvent = false;
sub = ws.onDidChangeWorkspace(e => {
try {
assert.equal(e.added.length, 0);
assert.equal(e.removed.length, 0);
assert.strictEqual(e.added.length, 0);
assert.strictEqual(e.removed.length, 0);
gotEvent = true;
} catch (error) {
finish(error);
}
});
ws.$acceptWorkspaceData({ id: 'foo', name: 'Test', folders: [aWorkspaceFolderData(URI.parse('foo:bar4'), 0), aWorkspaceFolderData(URI.parse('foo:bar3'), 1)] }); // simulate acknowledgement from main side
assert.equal(gotEvent, true);
assert.strictEqual(gotEvent, true);
sub.dispose();
assert.equal(ws.getWorkspaceFolders()![0], fifthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![1], fourthAddedFolder); // verify object is still live
assert.equal(fifthAddedFolder.index, 0);
assert.equal(fourthAddedFolder.index, 1);
assert.strictEqual(ws.getWorkspaceFolders()![0], fifthAddedFolder); // verify object is still live
assert.strictEqual(ws.getWorkspaceFolders()![1], fourthAddedFolder); // verify object is still live
assert.strictEqual(fifthAddedFolder.index, 0);
assert.strictEqual(fourthAddedFolder.index, 1);
//
// Add one folder after the other without waiting for confirmation (not supported currently)
//
assert.equal(true, ws.updateWorkspaceFolders(extensionDescriptor, 2, 0, asUpdateWorkspaceFolderData(URI.parse('foo:bar5'))));
assert.strictEqual(true, ws.updateWorkspaceFolders(extensionDescriptor, 2, 0, asUpdateWorkspaceFolderData(URI.parse('foo:bar5'))));
assert.equal(3, ws.workspace!.folders.length);
assert.equal(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar4').toString());
assert.equal(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar3').toString());
assert.equal(ws.workspace!.folders[2].uri.toString(), URI.parse('foo:bar5').toString());
assert.strictEqual(3, ws.workspace!.folders.length);
assert.strictEqual(ws.workspace!.folders[0].uri.toString(), URI.parse('foo:bar4').toString());
assert.strictEqual(ws.workspace!.folders[1].uri.toString(), URI.parse('foo:bar3').toString());
assert.strictEqual(ws.workspace!.folders[2].uri.toString(), URI.parse('foo:bar5').toString());
const sixthAddedFolder = ws.getWorkspaceFolders()![2];
gotEvent = false;
sub = ws.onDidChangeWorkspace(e => {
try {
assert.equal(e.added.length, 1);
assert.equal(e.added[0], sixthAddedFolder);
assert.strictEqual(e.added.length, 1);
assert.strictEqual(e.added[0], sixthAddedFolder);
gotEvent = true;
} catch (error) {
finish(error);
@@ -520,12 +520,12 @@ suite('ExtHostWorkspace', function () {
aWorkspaceFolderData(URI.parse('foo:bar5'), 2)
]
}); // simulate acknowledgement from main side
assert.equal(gotEvent, true);
assert.strictEqual(gotEvent, true);
sub.dispose();
assert.equal(ws.getWorkspaceFolders()![0], fifthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![1], fourthAddedFolder); // verify object is still live
assert.equal(ws.getWorkspaceFolders()![2], sixthAddedFolder); // verify object is still live
assert.strictEqual(ws.getWorkspaceFolders()![0], fifthAddedFolder); // verify object is still live
assert.strictEqual(ws.getWorkspaceFolders()![1], fourthAddedFolder); // verify object is still live
assert.strictEqual(ws.getWorkspaceFolders()![2], sixthAddedFolder); // verify object is still live
finish();
});
@@ -591,10 +591,10 @@ suite('ExtHostWorkspace', function () {
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
$startFileSearch(includePattern: string, _includeFolder: UriComponents | null, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | null> {
mainThreadCalled = true;
assert.equal(includePattern, 'foo');
assert.equal(_includeFolder, null);
assert.equal(excludePatternOrDisregardExcludes, null);
assert.equal(maxResults, 10);
assert.strictEqual(includePattern, 'foo');
assert.strictEqual(_includeFolder, null);
assert.strictEqual(excludePatternOrDisregardExcludes, null);
assert.strictEqual(maxResults, 10);
return Promise.resolve(null);
}
});
@@ -613,9 +613,9 @@ suite('ExtHostWorkspace', function () {
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
$startFileSearch(includePattern: string, _includeFolder: UriComponents | null, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | null> {
mainThreadCalled = true;
assert.equal(includePattern, 'glob/**');
assert.deepEqual(_includeFolder ? URI.from(_includeFolder).toJSON() : null, URI.file('/other/folder').toJSON());
assert.equal(excludePatternOrDisregardExcludes, null);
assert.strictEqual(includePattern, 'glob/**');
assert.deepStrictEqual(_includeFolder ? URI.from(_includeFolder).toJSON() : null, URI.file('/other/folder').toJSON());
assert.strictEqual(excludePatternOrDisregardExcludes, null);
return Promise.resolve(null);
}
});
@@ -642,9 +642,9 @@ suite('ExtHostWorkspace', function () {
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
$startFileSearch(includePattern: string, _includeFolder: UriComponents | null, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | null> {
mainThreadCalled = true;
assert.equal(includePattern, 'glob/**');
assert.deepEqual(_includeFolder, URI.file('/other/folder').toJSON());
assert.equal(excludePatternOrDisregardExcludes, false);
assert.strictEqual(includePattern, 'glob/**');
assert.deepStrictEqual(_includeFolder, URI.file('/other/folder').toJSON());
assert.strictEqual(excludePatternOrDisregardExcludes, false);
return Promise.resolve(null);
}
});
@@ -702,10 +702,10 @@ suite('ExtHostWorkspace', function () {
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
async $startTextSearch(query: IPatternInfo, folder: UriComponents | null, options: ITextQueryBuilderOptions, requestId: number, token: CancellationToken): Promise<ITextSearchComplete | null> {
mainThreadCalled = true;
assert.equal(query.pattern, 'foo');
assert.equal(folder, null);
assert.equal(options.includePattern, null);
assert.equal(options.excludePattern, null);
assert.strictEqual(query.pattern, 'foo');
assert.strictEqual(folder, null);
assert.strictEqual(options.includePattern, undefined);
assert.strictEqual(options.excludePattern, undefined);
return null;
}
});
@@ -723,10 +723,10 @@ suite('ExtHostWorkspace', function () {
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
async $startTextSearch(query: IPatternInfo, folder: UriComponents | null, options: ITextQueryBuilderOptions, requestId: number, token: CancellationToken): Promise<ITextSearchComplete | null> {
mainThreadCalled = true;
assert.equal(query.pattern, 'foo');
assert.equal(folder, null);
assert.equal(options.includePattern, '**/files');
assert.equal(options.excludePattern, null);
assert.strictEqual(query.pattern, 'foo');
assert.strictEqual(folder, null);
assert.strictEqual(options.includePattern, '**/files');
assert.strictEqual(options.excludePattern, undefined);
return null;
}
});
@@ -744,10 +744,10 @@ suite('ExtHostWorkspace', function () {
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
async $startTextSearch(query: IPatternInfo, folder: UriComponents | null, options: ITextQueryBuilderOptions, requestId: number, token: CancellationToken): Promise<ITextSearchComplete | null> {
mainThreadCalled = true;
assert.equal(query.pattern, 'foo');
assert.deepEqual(folder, URI.file('/other/folder').toJSON());
assert.equal(options.includePattern, 'glob/**');
assert.equal(options.excludePattern, null);
assert.strictEqual(query.pattern, 'foo');
assert.deepStrictEqual(folder, URI.file('/other/folder').toJSON());
assert.strictEqual(options.includePattern, 'glob/**');
assert.strictEqual(options.excludePattern, undefined);
return null;
}
});
@@ -783,10 +783,10 @@ suite('ExtHostWorkspace', function () {
rpcProtocol.set(MainContext.MainThreadWorkspace, new class extends mock<MainThreadWorkspace>() {
async $startTextSearch(query: IPatternInfo, folder: UriComponents | null, options: ITextQueryBuilderOptions, requestId: number, token: CancellationToken): Promise<ITextSearchComplete | null> {
mainThreadCalled = true;
assert.equal(query.pattern, 'foo');
assert.deepEqual(folder, null);
assert.equal(options.includePattern, null);
assert.equal(options.excludePattern, 'glob/**'); // exclude folder is ignored...
assert.strictEqual(query.pattern, 'foo');
assert.deepStrictEqual(folder, null);
assert.strictEqual(options.includePattern, undefined);
assert.strictEqual(options.excludePattern, 'glob/**'); // exclude folder is ignored...
return null;
}
});

View File

@@ -15,7 +15,7 @@ suite('MainThreadCommands', function () {
test('dispose on unregister', function () {
const commands = new MainThreadCommands(SingleProxyRPCProtocol(null), undefined!, new class extends mock<IExtensionService>() { });
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
assert.strictEqual(CommandsRegistry.getCommand('foo'), undefined);
// register
commands.$registerCommand('foo');
@@ -23,13 +23,13 @@ suite('MainThreadCommands', function () {
// unregister
commands.$unregisterCommand('foo');
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
assert.strictEqual(CommandsRegistry.getCommand('foo'), undefined);
});
test('unregister all on dispose', function () {
const commands = new MainThreadCommands(SingleProxyRPCProtocol(null), undefined!, new class extends mock<IExtensionService>() { });
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
assert.strictEqual(CommandsRegistry.getCommand('foo'), undefined);
commands.$registerCommand('foo');
commands.$registerCommand('bar');
@@ -39,8 +39,8 @@ suite('MainThreadCommands', function () {
commands.dispose();
assert.equal(CommandsRegistry.getCommand('foo'), undefined);
assert.equal(CommandsRegistry.getCommand('bar'), undefined);
assert.strictEqual(CommandsRegistry.getCommand('foo'), undefined);
assert.strictEqual(CommandsRegistry.getCommand('bar'), undefined);
});
test('activate and throw when needed', async function () {
@@ -70,18 +70,18 @@ suite('MainThreadCommands', function () {
await commands.$executeCommand('bazz', [1, 2, { n: 3 }], true);
assert.ok(false);
} catch (e) {
assert.deepEqual(activations, ['onCommand:bazz']);
assert.equal((<Error>e).message, '$executeCommand:retry');
assert.deepStrictEqual(activations, ['onCommand:bazz']);
assert.strictEqual((<Error>e).message, '$executeCommand:retry');
}
// case 2: no arguments and retry
runs.length = 0;
await commands.$executeCommand('bazz', [], true);
assert.deepEqual(runs, ['bazz']);
assert.deepStrictEqual(runs, ['bazz']);
// case 3: arguments and no retry
runs.length = 0;
await commands.$executeCommand('bazz', [1, 2, true], false);
assert.deepEqual(runs, ['bazz']);
assert.deepStrictEqual(runs, ['bazz']);
});
});

View File

@@ -65,7 +65,7 @@ suite('MainThreadConfiguration', function () {
testObject.$updateConfigurationOption(null, 'extHostConfiguration.resource', 'value', undefined, undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
test('update resource configuration without configuration target defaults to workspace in folder workspace when resource is provider', function () {
@@ -74,7 +74,7 @@ suite('MainThreadConfiguration', function () {
testObject.$updateConfigurationOption(null, 'extHostConfiguration.resource', 'value', { resource: URI.file('abc') }, undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
test('update resource configuration without configuration target defaults to workspace in folder workspace when no resource is provider', function () {
@@ -83,7 +83,7 @@ suite('MainThreadConfiguration', function () {
testObject.$updateConfigurationOption(null, 'extHostConfiguration.resource', 'value', undefined, undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
test('update window configuration without configuration target defaults to workspace in multi root workspace when no resource is provided', function () {
@@ -92,7 +92,7 @@ suite('MainThreadConfiguration', function () {
testObject.$updateConfigurationOption(null, 'extHostConfiguration.window', 'value', undefined, undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
test('update window configuration without configuration target defaults to workspace in multi root workspace when resource is provided', function () {
@@ -101,7 +101,7 @@ suite('MainThreadConfiguration', function () {
testObject.$updateConfigurationOption(null, 'extHostConfiguration.window', 'value', { resource: URI.file('abc') }, undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
test('update window configuration without configuration target defaults to workspace in folder workspace when resource is provider', function () {
@@ -110,7 +110,7 @@ suite('MainThreadConfiguration', function () {
testObject.$updateConfigurationOption(null, 'extHostConfiguration.window', 'value', { resource: URI.file('abc') }, undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
test('update window configuration without configuration target defaults to workspace in folder workspace when no resource is provider', function () {
@@ -119,7 +119,7 @@ suite('MainThreadConfiguration', function () {
testObject.$updateConfigurationOption(null, 'extHostConfiguration.window', 'value', undefined, undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
test('update resource configuration without configuration target defaults to folder', function () {
@@ -128,7 +128,7 @@ suite('MainThreadConfiguration', function () {
testObject.$updateConfigurationOption(null, 'extHostConfiguration.resource', 'value', { resource: URI.file('abc') }, undefined);
assert.equal(ConfigurationTarget.WORKSPACE_FOLDER, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE_FOLDER, target.args[0][3]);
});
test('update configuration with user configuration target', function () {
@@ -137,7 +137,7 @@ suite('MainThreadConfiguration', function () {
testObject.$updateConfigurationOption(ConfigurationTarget.USER, 'extHostConfiguration.window', 'value', { resource: URI.file('abc') }, undefined);
assert.equal(ConfigurationTarget.USER, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.USER, target.args[0][3]);
});
test('update configuration with workspace configuration target', function () {
@@ -146,7 +146,7 @@ suite('MainThreadConfiguration', function () {
testObject.$updateConfigurationOption(ConfigurationTarget.WORKSPACE, 'extHostConfiguration.window', 'value', { resource: URI.file('abc') }, undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
test('update configuration with folder configuration target', function () {
@@ -155,7 +155,7 @@ suite('MainThreadConfiguration', function () {
testObject.$updateConfigurationOption(ConfigurationTarget.WORKSPACE_FOLDER, 'extHostConfiguration.window', 'value', { resource: URI.file('abc') }, undefined);
assert.equal(ConfigurationTarget.WORKSPACE_FOLDER, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE_FOLDER, target.args[0][3]);
});
test('remove resource configuration without configuration target defaults to workspace in multi root workspace when no resource is provided', function () {
@@ -164,7 +164,7 @@ suite('MainThreadConfiguration', function () {
testObject.$removeConfigurationOption(null, 'extHostConfiguration.resource', undefined, undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
test('remove resource configuration without configuration target defaults to workspace in folder workspace when resource is provider', function () {
@@ -173,7 +173,7 @@ suite('MainThreadConfiguration', function () {
testObject.$removeConfigurationOption(null, 'extHostConfiguration.resource', { resource: URI.file('abc') }, undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
test('remove resource configuration without configuration target defaults to workspace in folder workspace when no resource is provider', function () {
@@ -182,7 +182,7 @@ suite('MainThreadConfiguration', function () {
testObject.$removeConfigurationOption(null, 'extHostConfiguration.resource', undefined, undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
test('remove window configuration without configuration target defaults to workspace in multi root workspace when no resource is provided', function () {
@@ -191,7 +191,7 @@ suite('MainThreadConfiguration', function () {
testObject.$removeConfigurationOption(null, 'extHostConfiguration.window', undefined, undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
test('remove window configuration without configuration target defaults to workspace in multi root workspace when resource is provided', function () {
@@ -200,7 +200,7 @@ suite('MainThreadConfiguration', function () {
testObject.$removeConfigurationOption(null, 'extHostConfiguration.window', { resource: URI.file('abc') }, undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
test('remove window configuration without configuration target defaults to workspace in folder workspace when resource is provider', function () {
@@ -209,7 +209,7 @@ suite('MainThreadConfiguration', function () {
testObject.$removeConfigurationOption(null, 'extHostConfiguration.window', { resource: URI.file('abc') }, undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
test('remove window configuration without configuration target defaults to workspace in folder workspace when no resource is provider', function () {
@@ -218,7 +218,7 @@ suite('MainThreadConfiguration', function () {
testObject.$removeConfigurationOption(null, 'extHostConfiguration.window', undefined, undefined);
assert.equal(ConfigurationTarget.WORKSPACE, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE, target.args[0][3]);
});
test('remove configuration without configuration target defaults to folder', function () {
@@ -227,6 +227,6 @@ suite('MainThreadConfiguration', function () {
testObject.$removeConfigurationOption(null, 'extHostConfiguration.resource', { resource: URI.file('abc') }, undefined);
assert.equal(ConfigurationTarget.WORKSPACE_FOLDER, target.args[0][3]);
assert.strictEqual(ConfigurationTarget.WORKSPACE_FOLDER, target.args[0][3]);
});
});

View File

@@ -10,6 +10,7 @@ import { URI } from 'vs/base/common/uri';
import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
import { mock } from 'vs/workbench/test/common/workbenchTestServices';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
import { ExtensionHostKind } from 'vs/workbench/services/extensions/common/extensions';
suite('MainThreadDiagnostics', function () {
@@ -25,6 +26,7 @@ suite('MainThreadDiagnostics', function () {
let diag = new MainThreadDiagnostics(
new class implements IExtHostContext {
remoteAuthority = '';
extensionHostKind = ExtensionHostKind.LocalProcess;
assertRegistered() { }
set(v: any): any { return null; }
getProxy(): any {
@@ -51,8 +53,8 @@ suite('MainThreadDiagnostics', function () {
source: 'me'
}]]]);
assert.equal(markerService.read().length, 1);
assert.strictEqual(markerService.read().length, 1);
diag.dispose();
assert.equal(markerService.read().length, 0);
assert.strictEqual(markerService.read().length, 0);
});
});

View File

@@ -23,13 +23,13 @@ suite('MainThreadDocumentContentProviders', function () {
let providers = new MainThreadDocumentContentProviders(new TestRPCProtocol(), null!, null!,
new class extends mock<IModelService>() {
getModel(_uri: URI) {
assert.equal(uri.toString(), _uri.toString());
assert.strictEqual(uri.toString(), _uri.toString());
return model;
}
},
new class extends mock<IEditorWorkerService>() {
computeMoreMinimalEdits(_uri: URI, data: TextEdit[] | undefined) {
assert.equal(model.getValue(), '1');
assert.strictEqual(model.getValue(), '1');
return Promise.resolve(data);
}
},

View File

@@ -32,7 +32,7 @@ suite('BoundModelReferenceCollection', () => {
});
await timeout(30);
assert.equal(didDispose, true);
assert.strictEqual(didDispose, true);
});
test('max size', () => {
@@ -66,7 +66,7 @@ suite('BoundModelReferenceCollection', () => {
}
});
assert.deepEqual(disposed, [0, 1]);
assert.deepStrictEqual(disposed, [0, 1]);
});
test('dispose uri', () => {
@@ -119,15 +119,15 @@ suite('BoundModelReferenceCollection', () => {
});
col.remove(URI.parse('test:///unknown'));
assert.equal(disposed.length, 0);
assert.strictEqual(disposed.length, 0);
col.remove(URI.parse('test:///farboo'));
assert.deepEqual(disposed, [0]);
assert.deepStrictEqual(disposed, [0]);
disposed = [];
col.remove(URI.parse('test:///boo'));
assert.deepEqual(disposed, [2, 3]);
assert.deepStrictEqual(disposed, [2, 3]);
});
});

View File

@@ -110,14 +110,14 @@ suite('MainThreadDocumentsAndEditors', () => {
modelService.createModel('farboo', null);
assert.equal(deltas.length, 1);
assert.strictEqual(deltas.length, 1);
const [delta] = deltas;
assert.equal(delta.addedDocuments!.length, 1);
assert.equal(delta.removedDocuments, undefined);
assert.equal(delta.addedEditors, undefined);
assert.equal(delta.removedEditors, undefined);
assert.equal(delta.newActiveEditor, null);
assert.strictEqual(delta.addedDocuments!.length, 1);
assert.strictEqual(delta.removedDocuments, undefined);
assert.strictEqual(delta.addedEditors, undefined);
assert.strictEqual(delta.removedEditors, undefined);
assert.strictEqual(delta.newActiveEditor, undefined);
});
test('ignore huge model', function () {
@@ -126,13 +126,13 @@ suite('MainThreadDocumentsAndEditors', () => {
const model = modelService.createModel(hugeModelString, null);
assert.ok(model.isTooLargeForSyncing());
assert.equal(deltas.length, 1);
assert.strictEqual(deltas.length, 1);
const [delta] = deltas;
assert.equal(delta.newActiveEditor, null);
assert.equal(delta.addedDocuments, undefined);
assert.equal(delta.removedDocuments, undefined);
assert.equal(delta.addedEditors, undefined);
assert.equal(delta.removedEditors, undefined);
assert.strictEqual(delta.newActiveEditor, null);
assert.strictEqual(delta.addedDocuments, undefined);
assert.strictEqual(delta.removedDocuments, undefined);
assert.strictEqual(delta.addedEditors, undefined);
assert.strictEqual(delta.removedEditors, undefined);
});
test('ignore simple widget model', function () {
@@ -141,13 +141,13 @@ suite('MainThreadDocumentsAndEditors', () => {
const model = modelService.createModel('test', null, undefined, true);
assert.ok(model.isForSimpleWidget);
assert.equal(deltas.length, 1);
assert.strictEqual(deltas.length, 1);
const [delta] = deltas;
assert.equal(delta.newActiveEditor, null);
assert.equal(delta.addedDocuments, undefined);
assert.equal(delta.removedDocuments, undefined);
assert.equal(delta.addedEditors, undefined);
assert.equal(delta.removedEditors, undefined);
assert.strictEqual(delta.newActiveEditor, null);
assert.strictEqual(delta.addedDocuments, undefined);
assert.strictEqual(delta.removedDocuments, undefined);
assert.strictEqual(delta.addedEditors, undefined);
assert.strictEqual(delta.removedEditors, undefined);
});
test('ignore huge model from editor', function () {
@@ -156,22 +156,22 @@ suite('MainThreadDocumentsAndEditors', () => {
const model = modelService.createModel(hugeModelString, null);
const editor = myCreateTestCodeEditor(model);
assert.equal(deltas.length, 1);
assert.strictEqual(deltas.length, 1);
deltas.length = 0;
assert.equal(deltas.length, 0);
assert.strictEqual(deltas.length, 0);
editor.dispose();
});
test('ignore editor w/o model', () => {
const editor = myCreateTestCodeEditor(undefined);
assert.equal(deltas.length, 1);
assert.strictEqual(deltas.length, 1);
const [delta] = deltas;
assert.equal(delta.newActiveEditor, null);
assert.equal(delta.addedDocuments, undefined);
assert.equal(delta.removedDocuments, undefined);
assert.equal(delta.addedEditors, undefined);
assert.equal(delta.removedEditors, undefined);
assert.strictEqual(delta.newActiveEditor, null);
assert.strictEqual(delta.addedDocuments, undefined);
assert.strictEqual(delta.removedDocuments, undefined);
assert.strictEqual(delta.addedEditors, undefined);
assert.strictEqual(delta.removedEditors, undefined);
editor.dispose();
});
@@ -182,19 +182,19 @@ suite('MainThreadDocumentsAndEditors', () => {
const model = modelService.createModel('farboo', null);
const editor = myCreateTestCodeEditor(model);
assert.equal(deltas.length, 2);
assert.strictEqual(deltas.length, 2);
const [first, second] = deltas;
assert.equal(first.addedDocuments!.length, 1);
assert.equal(first.newActiveEditor, null);
assert.equal(first.removedDocuments, undefined);
assert.equal(first.addedEditors, undefined);
assert.equal(first.removedEditors, undefined);
assert.strictEqual(first.addedDocuments!.length, 1);
assert.strictEqual(first.newActiveEditor, undefined);
assert.strictEqual(first.removedDocuments, undefined);
assert.strictEqual(first.addedEditors, undefined);
assert.strictEqual(first.removedEditors, undefined);
assert.equal(second.addedEditors!.length, 1);
assert.equal(second.addedDocuments, undefined);
assert.equal(second.removedDocuments, undefined);
assert.equal(second.removedEditors, undefined);
assert.equal(second.newActiveEditor, undefined);
assert.strictEqual(second.addedEditors!.length, 1);
assert.strictEqual(second.addedDocuments, undefined);
assert.strictEqual(second.removedDocuments, undefined);
assert.strictEqual(second.removedEditors, undefined);
assert.strictEqual(second.newActiveEditor, undefined);
editor.dispose();
});
@@ -208,14 +208,14 @@ suite('MainThreadDocumentsAndEditors', () => {
deltas.length = 0;
modelService.destroyModel(model.uri);
assert.equal(deltas.length, 1);
assert.strictEqual(deltas.length, 1);
const [first] = deltas;
assert.equal(first.newActiveEditor, null);
assert.equal(first.removedEditors!.length, 1);
assert.equal(first.removedDocuments!.length, 1);
assert.equal(first.addedDocuments, undefined);
assert.equal(first.addedEditors, undefined);
assert.strictEqual(first.newActiveEditor, undefined);
assert.strictEqual(first.removedEditors!.length, 1);
assert.strictEqual(first.removedDocuments!.length, 1);
assert.strictEqual(first.addedDocuments, undefined);
assert.strictEqual(first.addedEditors, undefined);
editor.dispose();
});

View File

@@ -19,7 +19,7 @@ import { Range } from 'vs/editor/common/core/range';
import { Position } from 'vs/editor/common/core/position';
import { IModelService } from 'vs/editor/common/services/modelService';
import { EditOperation } from 'vs/editor/common/core/editOperation';
import { TestFileService, TestEditorService, TestEditorGroupsService, TestEnvironmentService } from 'vs/workbench/test/browser/workbenchTestServices';
import { TestFileService, TestEditorService, TestEditorGroupsService, TestEnvironmentService, TestLifecycleService } from 'vs/workbench/test/browser/workbenchTestServices';
import { BulkEditService } from 'vs/workbench/contrib/bulkEdit/browser/bulkEditService';
import { NullLogService, ILogService } from 'vs/platform/log/common/log';
import { ITextModelService, IResolvedTextEditorModel } from 'vs/editor/common/services/resolverService';
@@ -40,7 +40,7 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { ILabelService } from 'vs/platform/label/common/label';
import { IWorkingCopyFileService } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
import { IWorkingCopyFileService, IMoveOperation, IDeleteOperation, ICopyOperation, ICreateFileOperation, ICreateOperation } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
import { TestDialogService } from 'vs/platform/dialogs/test/common/testDialogService';
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
@@ -50,6 +50,9 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
import { TestTextResourcePropertiesService, TestContextService } from 'vs/workbench/test/common/workbenchTestServices';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
import { extUri } from 'vs/base/common/resources';
import { ITextSnapshot } from 'vs/editor/common/model';
import { VSBuffer, VSBufferReadable } from 'vs/base/common/buffer';
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
suite('MainThreadEditors', () => {
@@ -92,6 +95,7 @@ suite('MainThreadEditors', () => {
services.set(ICodeEditorService, new TestCodeEditorService());
services.set(IFileService, new TestFileService());
services.set(IEditorService, new TestEditorService());
services.set(ILifecycleService, new TestLifecycleService());
services.set(IEditorGroupsService, new TestEditorGroupsService());
services.set(ITextFileService, new class extends mock<ITextFileService>() {
isDirty() { return false; }
@@ -100,26 +104,40 @@ suite('MainThreadEditors', () => {
onDidRevert: Event.None,
onDidChangeDirty: Event.None
};
create(operations: { resource: URI }[]) {
for (const o of operations) {
createdResources.add(o.resource);
}
return Promise.resolve(Object.create(null));
}
async getEncodedReadable(resource: URI, value?: string | ITextSnapshot): Promise<VSBuffer | VSBufferReadable | undefined> {
return undefined;
}
});
services.set(IWorkingCopyFileService, new class extends mock<IWorkingCopyFileService>() {
onDidRunWorkingCopyFileOperation = Event.None;
create(resource: URI) {
createdResources.add(resource);
createFolder(operations: ICreateOperation[]): any {
this.create(operations);
}
create(operations: ICreateFileOperation[]) {
for (const operation of operations) {
createdResources.add(operation.resource);
}
return Promise.resolve(Object.create(null));
}
move(files: { source: URI, target: URI }[]) {
const { source, target } = files[0];
move(operations: IMoveOperation[]) {
const { source, target } = operations[0].file;
movedResources.set(source, target);
return Promise.resolve(Object.create(null));
}
copy(files: { source: URI, target: URI }[]) {
const { source, target } = files[0];
copy(operations: ICopyOperation[]) {
const { source, target } = operations[0].file;
copiedResources.set(source, target);
return Promise.resolve(Object.create(null));
}
delete(resources: URI[]) {
for (const resource of resources) {
deletedResources.add(resource);
delete(operations: IDeleteOperation[]) {
for (const operation of operations) {
deletedResources.add(operation.resource);
}
return Promise.resolve(undefined);
}
@@ -183,7 +201,7 @@ suite('MainThreadEditors', () => {
model.applyEdits([EditOperation.insert(new Position(0, 0), 'something')]);
return editors.$tryApplyWorkspaceEdit({ edits: [workspaceResourceEdit] }).then((result) => {
assert.equal(result, false);
assert.strictEqual(result, false);
});
});
@@ -212,11 +230,11 @@ suite('MainThreadEditors', () => {
let p1 = editors.$tryApplyWorkspaceEdit({ edits: [workspaceResourceEdit1] }).then((result) => {
// first edit request succeeds
assert.equal(result, true);
assert.strictEqual(result, true);
});
let p2 = editors.$tryApplyWorkspaceEdit({ edits: [workspaceResourceEdit2] }).then((result) => {
// second edit request fails
assert.equal(result, false);
assert.strictEqual(result, false);
});
return Promise.all([p1, p2]);
});
@@ -229,10 +247,10 @@ suite('MainThreadEditors', () => {
{ _type: WorkspaceEditType.File, oldUri: resource, newUri: undefined, options: undefined }
]
}).then((result) => {
assert.equal(result, true);
assert.equal(movedResources.get(resource), resource);
assert.equal(createdResources.has(resource), true);
assert.equal(deletedResources.has(resource), true);
assert.strictEqual(result, true);
assert.strictEqual(movedResources.get(resource), resource);
assert.strictEqual(createdResources.has(resource), true);
assert.strictEqual(deletedResources.has(resource), true);
});
});
});

View File

@@ -17,6 +17,7 @@ import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { ViewDescriptorService } from 'vs/workbench/services/views/browser/viewDescriptorService';
import { CustomTreeView } from 'vs/workbench/browser/parts/views/treeView';
import { ExtensionHostKind } from 'vs/workbench/services/extensions/common/extensions';
suite('MainThreadHostTreeView', function () {
const testTreeViewId = 'testTreeView';
@@ -47,7 +48,7 @@ suite('MainThreadHostTreeView', function () {
const instantiationService: TestInstantiationService = <TestInstantiationService>workbenchInstantiationService();
const viewDescriptorService = instantiationService.createInstance(ViewDescriptorService);
instantiationService.stub(IViewDescriptorService, viewDescriptorService);
container = Registry.as<IViewContainersRegistry>(Extensions.ViewContainersRegistry).registerViewContainer({ id: 'testContainer', name: 'test', ctorDescriptor: new SyncDescriptor(<any>{}) }, ViewContainerLocation.Sidebar);
container = Registry.as<IViewContainersRegistry>(Extensions.ViewContainersRegistry).registerViewContainer({ id: 'testContainer', title: 'test', ctorDescriptor: new SyncDescriptor(<any>{}) }, ViewContainerLocation.Sidebar);
const viewDescriptor: ITreeViewDescriptor = {
id: testTreeViewId,
ctorDescriptor: null!,
@@ -61,6 +62,7 @@ suite('MainThreadHostTreeView', function () {
mainThreadTreeViews = new MainThreadTreeViews(
new class implements IExtHostContext {
remoteAuthority = '';
extensionHostKind = ExtensionHostKind.LocalProcess;
assertRegistered() { }
set(v: any): any { return null; }
getProxy(): any {

View File

@@ -8,6 +8,7 @@ import { CharCode } from 'vs/base/common/charCode';
import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
import { isThenable } from 'vs/base/common/async';
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { ExtensionHostKind } from 'vs/workbench/services/extensions/common/extensions';
export function SingleProxyRPCProtocol(thing: any): IExtHostContext & IExtHostRpcService {
return {
@@ -20,7 +21,8 @@ export function SingleProxyRPCProtocol(thing: any): IExtHostContext & IExtHostRp
return value;
},
assertRegistered: undefined!,
drain: undefined!
drain: undefined!,
extensionHostKind: ExtensionHostKind.LocalProcess
};
}
@@ -28,6 +30,7 @@ export class TestRPCProtocol implements IExtHostContext, IExtHostRpcService {
public _serviceBrand: undefined;
public remoteAuthority = null!;
public extensionHostKind = ExtensionHostKind.LocalProcess;
private _callCountValue: number = 0;
private _idle?: Promise<any>;

View File

@@ -10,7 +10,7 @@ import { workbenchInstantiationService, TestEditorService } from 'vs/workbench/t
import { IModelService } from 'vs/editor/common/services/modelService';
import { IModeService } from 'vs/editor/common/services/modeService';
import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
import { RangeHighlightDecorations } from 'vs/workbench/browser/parts/editor/rangeDecorations';
import { RangeHighlightDecorations } from 'vs/workbench/browser/codeeditor';
import { TextModel } from 'vs/editor/common/model/textModel';
import { createTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
import { Range, IRange } from 'vs/editor/common/core/range';

View File

@@ -5,100 +5,101 @@
import * as assert from 'assert';
import { Part } from 'vs/workbench/browser/part';
import * as Types from 'vs/base/common/types';
import { isEmptyObject } from 'vs/base/common/types';
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
import { append, $, hide } from 'vs/base/browser/dom';
import { TestLayoutService } from 'vs/workbench/test/browser/workbenchTestServices';
import { StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { TestStorageService } from 'vs/workbench/test/common/workbenchTestServices';
class SimplePart extends Part {
minimumWidth: number = 50;
maximumWidth: number = 50;
minimumHeight: number = 50;
maximumHeight: number = 50;
layout(width: number, height: number): void {
throw new Error('Method not implemented.');
}
toJSON(): object {
throw new Error('Method not implemented.');
}
}
class MyPart extends SimplePart {
constructor(private expectedParent: HTMLElement) {
super('myPart', { hasTitle: true }, new TestThemeService(), new TestStorageService(), new TestLayoutService());
}
createTitleArea(parent: HTMLElement): HTMLElement {
assert.strictEqual(parent, this.expectedParent);
return super.createTitleArea(parent)!;
}
createContentArea(parent: HTMLElement): HTMLElement {
assert.strictEqual(parent, this.expectedParent);
return super.createContentArea(parent)!;
}
getMemento(scope: StorageScope, target: StorageTarget) {
return super.getMemento(scope, target);
}
saveState(): void {
return super.saveState();
}
}
class MyPart2 extends SimplePart {
constructor() {
super('myPart2', { hasTitle: true }, new TestThemeService(), new TestStorageService(), new TestLayoutService());
}
createTitleArea(parent: HTMLElement): HTMLElement {
const titleContainer = append(parent, $('div'));
const titleLabel = append(titleContainer, $('span'));
titleLabel.id = 'myPart.title';
titleLabel.innerText = 'Title';
return titleContainer;
}
createContentArea(parent: HTMLElement): HTMLElement {
const contentContainer = append(parent, $('div'));
const contentSpan = append(contentContainer, $('span'));
contentSpan.id = 'myPart.content';
contentSpan.innerText = 'Content';
return contentContainer;
}
}
class MyPart3 extends SimplePart {
constructor() {
super('myPart2', { hasTitle: false }, new TestThemeService(), new TestStorageService(), new TestLayoutService());
}
createTitleArea(parent: HTMLElement): HTMLElement {
return null!;
}
createContentArea(parent: HTMLElement): HTMLElement {
const contentContainer = append(parent, $('div'));
const contentSpan = append(contentContainer, $('span'));
contentSpan.id = 'myPart.content';
contentSpan.innerText = 'Content';
return contentContainer;
}
}
suite('Workbench parts', () => {
class SimplePart extends Part {
minimumWidth: number = 50;
maximumWidth: number = 50;
minimumHeight: number = 50;
maximumHeight: number = 50;
layout(width: number, height: number): void {
throw new Error('Method not implemented.');
}
toJSON(): object {
throw new Error('Method not implemented.');
}
}
class MyPart extends SimplePart {
constructor(private expectedParent: HTMLElement) {
super('myPart', { hasTitle: true }, new TestThemeService(), new TestStorageService(), new TestLayoutService());
}
createTitleArea(parent: HTMLElement): HTMLElement {
assert.strictEqual(parent, this.expectedParent);
return super.createTitleArea(parent)!;
}
createContentArea(parent: HTMLElement): HTMLElement {
assert.strictEqual(parent, this.expectedParent);
return super.createContentArea(parent)!;
}
getMemento(scope: StorageScope, target: StorageTarget) {
return super.getMemento(scope, target);
}
saveState(): void {
return super.saveState();
}
}
class MyPart2 extends SimplePart {
constructor() {
super('myPart2', { hasTitle: true }, new TestThemeService(), new TestStorageService(), new TestLayoutService());
}
createTitleArea(parent: HTMLElement): HTMLElement {
const titleContainer = append(parent, $('div'));
const titleLabel = append(titleContainer, $('span'));
titleLabel.id = 'myPart.title';
titleLabel.innerText = 'Title';
return titleContainer;
}
createContentArea(parent: HTMLElement): HTMLElement {
const contentContainer = append(parent, $('div'));
const contentSpan = append(contentContainer, $('span'));
contentSpan.id = 'myPart.content';
contentSpan.innerText = 'Content';
return contentContainer;
}
}
class MyPart3 extends SimplePart {
constructor() {
super('myPart2', { hasTitle: false }, new TestThemeService(), new TestStorageService(), new TestLayoutService());
}
createTitleArea(parent: HTMLElement): HTMLElement {
return null!;
}
createContentArea(parent: HTMLElement): HTMLElement {
const contentContainer = append(parent, $('div'));
const contentSpan = append(contentContainer, $('span'));
contentSpan.id = 'myPart.content';
contentSpan.innerText = 'Content';
return contentContainer;
}
}
let fixture: HTMLElement;
let fixtureId = 'workbench-part-fixture';
@@ -146,7 +147,7 @@ suite('Workbench parts', () => {
part = new MyPart(b);
memento = part.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
assert(memento);
assert.strictEqual(Types.isEmptyObject(memento), true);
assert.strictEqual(isEmptyObject(memento), true);
});
test('Part Layout with Title and Content', function () {

View File

@@ -6,12 +6,13 @@
import * as assert from 'assert';
import { URI } from 'vs/base/common/uri';
import { WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { EditorBreadcrumbsModel, FileElement } from 'vs/workbench/browser/parts/editor/breadcrumbsModel';
import { BreadcrumbsModel, FileElement } from 'vs/workbench/browser/parts/editor/breadcrumbsModel';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { FileKind } from 'vs/platform/files/common/files';
import { TestContextService } from 'vs/workbench/test/common/workbenchTestServices';
import { Workspace } from 'vs/platform/workspace/test/common/testWorkspace';
import { mock } from 'vs/base/test/common/mock';
import { IOutlineService } from 'vs/workbench/services/outline/browser/outline';
suite('Breadcrumb Model', function () {
@@ -33,7 +34,7 @@ suite('Breadcrumb Model', function () {
test('only uri, inside workspace', function () {
let model = new EditorBreadcrumbsModel(URI.parse('foo:/bar/baz/ws/some/path/file.ts'), URI.parse('foo:/bar/baz/ws/some/path/file.ts'), undefined, configService, configService, workspaceService);
let model = new BreadcrumbsModel(URI.parse('foo:/bar/baz/ws/some/path/file.ts'), undefined, configService, workspaceService, new class extends mock<IOutlineService>() { });
let elements = model.getElements();
assert.equal(elements.length, 3);
@@ -48,7 +49,7 @@ suite('Breadcrumb Model', function () {
test('display uri matters for FileElement', function () {
let model = new EditorBreadcrumbsModel(URI.parse('foo:/bar/baz/ws/some/PATH/file.ts'), URI.parse('foo:/bar/baz/ws/some/path/file.ts'), undefined, configService, configService, workspaceService);
let model = new BreadcrumbsModel(URI.parse('foo:/bar/baz/ws/some/PATH/file.ts'), undefined, configService, workspaceService, new class extends mock<IOutlineService>() { });
let elements = model.getElements();
assert.equal(elements.length, 3);
@@ -63,7 +64,7 @@ suite('Breadcrumb Model', function () {
test('only uri, outside workspace', function () {
let model = new EditorBreadcrumbsModel(URI.parse('foo:/outside/file.ts'), URI.parse('foo:/outside/file.ts'), undefined, configService, configService, workspaceService);
let model = new BreadcrumbsModel(URI.parse('foo:/outside/file.ts'), undefined, configService, workspaceService, new class extends mock<IOutlineService>() { });
let elements = model.getElements();
assert.equal(elements.length, 2);

View File

@@ -12,15 +12,15 @@ import { workbenchInstantiationService, TestServiceAccessor, TestEditorInput } f
import { Schemas } from 'vs/base/common/network';
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
export class TestEditorInputWithPreferredResource extends TestEditorInput implements IEditorInputWithPreferredResource {
constructor(resource: URI, public preferredResource: URI, typeId: string) {
super(resource, typeId);
}
}
suite('Workbench editor', () => {
class TestEditorInputWithPreferredResource extends TestEditorInput implements IEditorInputWithPreferredResource {
constructor(resource: URI, public preferredResource: URI, typeId: string) {
super(resource, typeId);
}
}
let instantiationService: IInstantiationService;
let accessor: TestServiceAccessor;
@@ -41,38 +41,38 @@ suite('Workbench editor', () => {
const untitled = instantiationService.createInstance(UntitledTextEditorInput, service.create());
assert.equal(EditorResourceAccessor.getCanonicalUri(untitled)!.toString(), untitled.resource.toString());
assert.equal(EditorResourceAccessor.getCanonicalUri(untitled, { supportSideBySide: SideBySideEditor.PRIMARY })!.toString(), untitled.resource.toString());
assert.equal(EditorResourceAccessor.getCanonicalUri(untitled, { supportSideBySide: SideBySideEditor.SECONDARY })!.toString(), untitled.resource.toString());
assert.equal(EditorResourceAccessor.getCanonicalUri(untitled, { supportSideBySide: SideBySideEditor.BOTH })!.toString(), untitled.resource.toString());
assert.equal(EditorResourceAccessor.getCanonicalUri(untitled, { filterByScheme: Schemas.untitled })!.toString(), untitled.resource.toString());
assert.equal(EditorResourceAccessor.getCanonicalUri(untitled, { filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(untitled)!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(untitled, { supportSideBySide: SideBySideEditor.PRIMARY })!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(untitled, { supportSideBySide: SideBySideEditor.SECONDARY })!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(untitled, { supportSideBySide: SideBySideEditor.BOTH })!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(untitled, { filterByScheme: Schemas.untitled })!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(untitled, { filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), untitled.resource.toString());
assert.ok(!EditorResourceAccessor.getCanonicalUri(untitled, { filterByScheme: Schemas.file }));
assert.equal(EditorResourceAccessor.getOriginalUri(untitled)!.toString(), untitled.resource.toString());
assert.equal(EditorResourceAccessor.getOriginalUri(untitled, { supportSideBySide: SideBySideEditor.PRIMARY })!.toString(), untitled.resource.toString());
assert.equal(EditorResourceAccessor.getOriginalUri(untitled, { supportSideBySide: SideBySideEditor.SECONDARY })!.toString(), untitled.resource.toString());
assert.equal(EditorResourceAccessor.getOriginalUri(untitled, { supportSideBySide: SideBySideEditor.BOTH })!.toString(), untitled.resource.toString());
assert.equal(EditorResourceAccessor.getOriginalUri(untitled, { filterByScheme: Schemas.untitled })!.toString(), untitled.resource.toString());
assert.equal(EditorResourceAccessor.getOriginalUri(untitled, { filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(untitled)!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(untitled, { supportSideBySide: SideBySideEditor.PRIMARY })!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(untitled, { supportSideBySide: SideBySideEditor.SECONDARY })!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(untitled, { supportSideBySide: SideBySideEditor.BOTH })!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(untitled, { filterByScheme: Schemas.untitled })!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(untitled, { filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), untitled.resource.toString());
assert.ok(!EditorResourceAccessor.getOriginalUri(untitled, { filterByScheme: Schemas.file }));
const file = new TestEditorInput(URI.file('/some/path.txt'), 'editorResourceFileTest');
assert.equal(EditorResourceAccessor.getCanonicalUri(file)!.toString(), file.resource.toString());
assert.equal(EditorResourceAccessor.getCanonicalUri(file, { supportSideBySide: SideBySideEditor.PRIMARY })!.toString(), file.resource.toString());
assert.equal(EditorResourceAccessor.getCanonicalUri(file, { supportSideBySide: SideBySideEditor.SECONDARY })!.toString(), file.resource.toString());
assert.equal(EditorResourceAccessor.getCanonicalUri(file, { supportSideBySide: SideBySideEditor.BOTH })!.toString(), file.resource.toString());
assert.equal(EditorResourceAccessor.getCanonicalUri(file, { filterByScheme: Schemas.file })!.toString(), file.resource.toString());
assert.equal(EditorResourceAccessor.getCanonicalUri(file, { filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(file)!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(file, { supportSideBySide: SideBySideEditor.PRIMARY })!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(file, { supportSideBySide: SideBySideEditor.SECONDARY })!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(file, { supportSideBySide: SideBySideEditor.BOTH })!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(file, { filterByScheme: Schemas.file })!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(file, { filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), file.resource.toString());
assert.ok(!EditorResourceAccessor.getCanonicalUri(file, { filterByScheme: Schemas.untitled }));
assert.equal(EditorResourceAccessor.getOriginalUri(file)!.toString(), file.resource.toString());
assert.equal(EditorResourceAccessor.getOriginalUri(file, { supportSideBySide: SideBySideEditor.PRIMARY })!.toString(), file.resource.toString());
assert.equal(EditorResourceAccessor.getOriginalUri(file, { supportSideBySide: SideBySideEditor.SECONDARY })!.toString(), file.resource.toString());
assert.equal(EditorResourceAccessor.getOriginalUri(file, { supportSideBySide: SideBySideEditor.BOTH })!.toString(), file.resource.toString());
assert.equal(EditorResourceAccessor.getOriginalUri(file, { filterByScheme: Schemas.file })!.toString(), file.resource.toString());
assert.equal(EditorResourceAccessor.getOriginalUri(file, { filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(file)!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(file, { supportSideBySide: SideBySideEditor.PRIMARY })!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(file, { supportSideBySide: SideBySideEditor.SECONDARY })!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(file, { supportSideBySide: SideBySideEditor.BOTH })!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(file, { filterByScheme: Schemas.file })!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(file, { filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), file.resource.toString());
assert.ok(!EditorResourceAccessor.getOriginalUri(file, { filterByScheme: Schemas.untitled }));
const diffEditorInput = instantiationService.createInstance(DiffEditorInput, 'name', 'description', untitled, file, undefined);
@@ -80,47 +80,47 @@ suite('Workbench editor', () => {
assert.ok(!EditorResourceAccessor.getCanonicalUri(diffEditorInput));
assert.ok(!EditorResourceAccessor.getCanonicalUri(diffEditorInput, { filterByScheme: Schemas.file }));
assert.equal(EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.PRIMARY })!.toString(), file.resource.toString());
assert.equal(EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.PRIMARY, filterByScheme: Schemas.file })!.toString(), file.resource.toString());
assert.equal(EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.PRIMARY, filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.PRIMARY })!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.PRIMARY, filterByScheme: Schemas.file })!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.PRIMARY, filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), file.resource.toString());
assert.equal(EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.SECONDARY })!.toString(), untitled.resource.toString());
assert.equal(EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.SECONDARY, filterByScheme: Schemas.untitled })!.toString(), untitled.resource.toString());
assert.equal(EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.SECONDARY, filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.SECONDARY })!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.SECONDARY, filterByScheme: Schemas.untitled })!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.SECONDARY, filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), untitled.resource.toString());
assert.equal((EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH }) as { primary: URI, secondary: URI }).primary.toString(), file.resource.toString());
assert.equal((EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: Schemas.file }) as { primary: URI, secondary: URI }).primary.toString(), file.resource.toString());
assert.equal((EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: [Schemas.file, Schemas.untitled] }) as { primary: URI, secondary: URI }).primary.toString(), file.resource.toString());
assert.strictEqual((EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH }) as { primary: URI, secondary: URI }).primary.toString(), file.resource.toString());
assert.strictEqual((EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: Schemas.file }) as { primary: URI, secondary: URI }).primary.toString(), file.resource.toString());
assert.strictEqual((EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: [Schemas.file, Schemas.untitled] }) as { primary: URI, secondary: URI }).primary.toString(), file.resource.toString());
assert.equal((EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH }) as { primary: URI, secondary: URI }).secondary.toString(), untitled.resource.toString());
assert.equal((EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: Schemas.untitled }) as { primary: URI, secondary: URI }).secondary.toString(), untitled.resource.toString());
assert.equal((EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: [Schemas.file, Schemas.untitled] }) as { primary: URI, secondary: URI }).secondary.toString(), untitled.resource.toString());
assert.strictEqual((EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH }) as { primary: URI, secondary: URI }).secondary.toString(), untitled.resource.toString());
assert.strictEqual((EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: Schemas.untitled }) as { primary: URI, secondary: URI }).secondary.toString(), untitled.resource.toString());
assert.strictEqual((EditorResourceAccessor.getCanonicalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: [Schemas.file, Schemas.untitled] }) as { primary: URI, secondary: URI }).secondary.toString(), untitled.resource.toString());
assert.ok(!EditorResourceAccessor.getOriginalUri(diffEditorInput));
assert.ok(!EditorResourceAccessor.getOriginalUri(diffEditorInput, { filterByScheme: Schemas.file }));
assert.equal(EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.PRIMARY })!.toString(), file.resource.toString());
assert.equal(EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.PRIMARY, filterByScheme: Schemas.file })!.toString(), file.resource.toString());
assert.equal(EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.PRIMARY, filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.PRIMARY })!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.PRIMARY, filterByScheme: Schemas.file })!.toString(), file.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.PRIMARY, filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), file.resource.toString());
assert.equal(EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.SECONDARY })!.toString(), untitled.resource.toString());
assert.equal(EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.SECONDARY, filterByScheme: Schemas.untitled })!.toString(), untitled.resource.toString());
assert.equal(EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.SECONDARY, filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.SECONDARY })!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.SECONDARY, filterByScheme: Schemas.untitled })!.toString(), untitled.resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.SECONDARY, filterByScheme: [Schemas.file, Schemas.untitled] })!.toString(), untitled.resource.toString());
assert.equal((EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH }) as { primary: URI, secondary: URI }).primary.toString(), file.resource.toString());
assert.equal((EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: Schemas.file }) as { primary: URI, secondary: URI }).primary.toString(), file.resource.toString());
assert.equal((EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: [Schemas.file, Schemas.untitled] }) as { primary: URI, secondary: URI }).primary.toString(), file.resource.toString());
assert.strictEqual((EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH }) as { primary: URI, secondary: URI }).primary.toString(), file.resource.toString());
assert.strictEqual((EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: Schemas.file }) as { primary: URI, secondary: URI }).primary.toString(), file.resource.toString());
assert.strictEqual((EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: [Schemas.file, Schemas.untitled] }) as { primary: URI, secondary: URI }).primary.toString(), file.resource.toString());
assert.equal((EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH }) as { primary: URI, secondary: URI }).secondary.toString(), untitled.resource.toString());
assert.equal((EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: Schemas.untitled }) as { primary: URI, secondary: URI }).secondary.toString(), untitled.resource.toString());
assert.equal((EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: [Schemas.file, Schemas.untitled] }) as { primary: URI, secondary: URI }).secondary.toString(), untitled.resource.toString());
assert.strictEqual((EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH }) as { primary: URI, secondary: URI }).secondary.toString(), untitled.resource.toString());
assert.strictEqual((EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: Schemas.untitled }) as { primary: URI, secondary: URI }).secondary.toString(), untitled.resource.toString());
assert.strictEqual((EditorResourceAccessor.getOriginalUri(diffEditorInput, { supportSideBySide: SideBySideEditor.BOTH, filterByScheme: [Schemas.file, Schemas.untitled] }) as { primary: URI, secondary: URI }).secondary.toString(), untitled.resource.toString());
const resource = URI.file('/some/path.txt');
const preferredResource = URI.file('/some/PATH.txt');
const fileWithPreferredResource = new TestEditorInputWithPreferredResource(URI.file('/some/path.txt'), URI.file('/some/PATH.txt'), 'editorResourceFileTest');
assert.equal(EditorResourceAccessor.getCanonicalUri(fileWithPreferredResource)?.toString(), resource.toString());
assert.equal(EditorResourceAccessor.getOriginalUri(fileWithPreferredResource)?.toString(), preferredResource.toString());
assert.strictEqual(EditorResourceAccessor.getCanonicalUri(fileWithPreferredResource)?.toString(), resource.toString());
assert.strictEqual(EditorResourceAccessor.getOriginalUri(fileWithPreferredResource)?.toString(), preferredResource.toString());
});
});

View File

@@ -24,14 +24,15 @@ suite('Workbench editor model', () => {
test('TextDiffEditorModel', async () => {
const dispose = accessor.textModelResolverService.registerTextModelContentProvider('test', {
provideTextContent: function (resource: URI): Promise<ITextModel> {
provideTextContent: async function (resource: URI): Promise<ITextModel | null> {
if (resource.scheme === 'test') {
let modelContent = 'Hello Test';
let languageSelection = accessor.modeService.create('json');
return Promise.resolve(accessor.modelService.createModel(modelContent, languageSelection, resource));
return accessor.modelService.createModel(modelContent, languageSelection, resource);
}
return Promise.resolve(null!);
return null;
}
});

File diff suppressed because it is too large Load Diff

View File

@@ -8,15 +8,15 @@ import { EditorInput } from 'vs/workbench/common/editor';
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
import { workbenchInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
class MyEditorInput extends EditorInput {
readonly resource = undefined;
getTypeId(): string { return ''; }
resolve(): any { return null; }
}
suite('Workbench editor input', () => {
class MyEditorInput extends EditorInput {
readonly resource = undefined;
getTypeId(): string { return ''; }
resolve(): any { return null; }
}
test('EditorInput', () => {
let counter = 0;
let input = new MyEditorInput();
@@ -33,7 +33,7 @@ suite('Workbench editor input', () => {
});
input.dispose();
assert.equal(counter, 1);
assert.strictEqual(counter, 1);
});
test('DiffEditorInput', () => {
@@ -54,14 +54,14 @@ suite('Workbench editor input', () => {
let diffInput = instantiationService.createInstance(DiffEditorInput, 'name', 'description', input, otherInput, undefined);
assert.equal(diffInput.originalInput, input);
assert.equal(diffInput.modifiedInput, otherInput);
assert.strictEqual(diffInput.originalInput, input);
assert.strictEqual(diffInput.modifiedInput, otherInput);
assert(diffInput.matches(diffInput));
assert(!diffInput.matches(otherInput));
assert(!diffInput.matches(null));
diffInput.dispose();
assert.equal(counter, 0);
assert.strictEqual(counter, 0);
});
test('DiffEditorInput disposes when input inside disposes', function () {
@@ -89,6 +89,6 @@ suite('Workbench editor input', () => {
});
otherInput.dispose();
assert.equal(counter, 2);
assert.strictEqual(counter, 2);
});
});

View File

@@ -27,19 +27,33 @@ import { TestTextResourcePropertiesService } from 'vs/workbench/test/common/work
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
class MyEditorModel extends EditorModel { }
class MyTextEditorModel extends BaseTextEditorModel {
createTextEditorModel(value: ITextBufferFactory, resource?: URI, preferredMode?: string) {
return super.createTextEditorModel(value, resource, preferredMode);
}
isReadonly(): boolean {
return false;
}
}
suite('Workbench editor model', () => {
class MyEditorModel extends EditorModel { }
class MyTextEditorModel extends BaseTextEditorModel {
createTextEditorModel(value: ITextBufferFactory, resource?: URI, preferredMode?: string) {
return super.createTextEditorModel(value, resource, preferredMode);
}
isReadonly(): boolean {
return false;
}
}
function stubModelService(instantiationService: TestInstantiationService): IModelService {
const dialogService = new TestDialogService();
const notificationService = new TestNotificationService();
const undoRedoService = new UndoRedoService(dialogService, notificationService);
instantiationService.stub(IConfigurationService, new TestConfigurationService());
instantiationService.stub(ITextResourcePropertiesService, new TestTextResourcePropertiesService(instantiationService.get(IConfigurationService)));
instantiationService.stub(IDialogService, dialogService);
instantiationService.stub(INotificationService, notificationService);
instantiationService.stub(IUndoRedoService, undoRedoService);
instantiationService.stub(IThemeService, new TestThemeService());
return instantiationService.createInstance(ModelServiceImpl);
}
let instantiationService: TestInstantiationService;
let modeService: IModeService;
@@ -51,44 +65,31 @@ suite('Workbench editor model', () => {
test('EditorModel', async () => {
let counter = 0;
let m = new MyEditorModel();
const model = new MyEditorModel();
m.onDispose(() => {
model.onDispose(() => {
assert(true);
counter++;
});
const model = await m.load();
assert(model === m);
assert.equal(model.isDisposed(), false);
assert.strictEqual(m.isResolved(), true);
m.dispose();
assert.equal(counter, 1);
assert.equal(model.isDisposed(), true);
const resolvedModel = await model.load();
assert(resolvedModel === model);
assert.strictEqual(resolvedModel.isDisposed(), false);
assert.strictEqual(model.isResolved(), true);
model.dispose();
assert.strictEqual(counter, 1);
assert.strictEqual(resolvedModel.isDisposed(), true);
});
test('BaseTextEditorModel', async () => {
let modelService = stubModelService(instantiationService);
let m = new MyTextEditorModel(modelService, modeService);
const model = await m.load() as MyTextEditorModel;
const model = new MyTextEditorModel(modelService, modeService);
const resolvedModel = await model.load() as MyTextEditorModel;
assert(model === m);
model.createTextEditorModel(createTextBufferFactory('foo'), null!, 'text/plain');
assert.strictEqual(m.isResolved(), true);
m.dispose();
assert(resolvedModel === model);
resolvedModel.createTextEditorModel(createTextBufferFactory('foo'), null!, 'text/plain');
assert.strictEqual(model.isResolved(), true);
model.dispose();
});
function stubModelService(instantiationService: TestInstantiationService): IModelService {
const dialogService = new TestDialogService();
const notificationService = new TestNotificationService();
const undoRedoService = new UndoRedoService(dialogService, notificationService);
instantiationService.stub(IConfigurationService, new TestConfigurationService());
instantiationService.stub(ITextResourcePropertiesService, new TestTextResourcePropertiesService(instantiationService.get(IConfigurationService)));
instantiationService.stub(IDialogService, dialogService);
instantiationService.stub(INotificationService, notificationService);
instantiationService.stub(IUndoRedoService, undoRedoService);
instantiationService.stub(IThemeService, new TestThemeService());
return instantiationService.createInstance(ModelServiceImpl);
}
});

View File

@@ -7,25 +7,25 @@ import * as assert from 'assert';
import { EditorPane, EditorMemento } from 'vs/workbench/browser/parts/editor/editorPane';
import { EditorInput, EditorOptions, IEditorInputFactory, IEditorInputFactoryRegistry, Extensions as EditorExtensions } from 'vs/workbench/common/editor';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import * as Platform from 'vs/platform/registry/common/platform';
import { Registry } from 'vs/platform/registry/common/platform';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { workbenchInstantiationService, TestEditorGroupView, TestEditorGroupsService } from 'vs/workbench/test/browser/workbenchTestServices';
import { workbenchInstantiationService, TestEditorGroupView, TestEditorGroupsService, registerTestResourceEditor } from 'vs/workbench/test/browser/workbenchTestServices';
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
import { URI } from 'vs/base/common/uri';
import { IEditorRegistry, Extensions, EditorDescriptor } from 'vs/workbench/browser/editor';
import { CancellationToken } from 'vs/base/common/cancellation';
import { IEditorModel } from 'vs/platform/editor/common/editor';
import { dispose } from 'vs/base/common/lifecycle';
import { DisposableStore, dispose } from 'vs/base/common/lifecycle';
import { TestStorageService } from 'vs/workbench/test/common/workbenchTestServices';
import { extUri } from 'vs/base/common/resources';
const NullThemeService = new TestThemeService();
let EditorRegistry: IEditorRegistry = Platform.Registry.as(Extensions.Editors);
let EditorInputRegistry: IEditorInputFactoryRegistry = Platform.Registry.as(EditorExtensions.EditorInputFactories);
let EditorRegistry: IEditorRegistry = Registry.as(Extensions.Editors);
let EditorInputRegistry: IEditorInputFactoryRegistry = Registry.as(EditorExtensions.EditorInputFactories);
export class MyEditor extends EditorPane {
@@ -107,11 +107,11 @@ suite('Workbench EditorPane', () => {
assert(!e.input);
await e.setInput(input, options, Object.create(null), CancellationToken.None);
assert.strictEqual(input, e.input);
assert.strictEqual(<any>input, e.input);
const group = new TestEditorGroupView(1);
e.setVisible(true, group);
assert(e.isVisible());
assert.equal(e.group, group);
assert.strictEqual(e.group, group);
input.onDispose(() => {
assert(false);
});
@@ -139,8 +139,8 @@ suite('Workbench EditorPane', () => {
const dispose1 = EditorRegistry.registerEditor(d1, [new SyncDescriptor(MyInput)]);
const dispose2 = EditorRegistry.registerEditor(d2, [new SyncDescriptor(MyInput), new SyncDescriptor(MyOtherInput)]);
assert.equal(EditorRegistry.getEditors().length, oldEditorsCnt + 2);
assert.equal((<any>EditorRegistry).getEditorInputs().length, oldInputCnt + 3);
assert.strictEqual(EditorRegistry.getEditors().length, oldEditorsCnt + 2);
assert.strictEqual((<any>EditorRegistry).getEditorInputs().length, oldInputCnt + 3);
assert.strictEqual(EditorRegistry.getEditor(new MyInput()), d2);
assert.strictEqual(EditorRegistry.getEditor(new MyOtherInput()), d2);
@@ -155,7 +155,10 @@ suite('Workbench EditorPane', () => {
test('Editor Lookup favors specific class over superclass (match on specific class)', function () {
let d1 = EditorDescriptor.create(MyEditor, 'id1', 'name');
const disposable = EditorRegistry.registerEditor(d1, [new SyncDescriptor(MyResourceEditorInput)]);
const disposables = new DisposableStore();
disposables.add(registerTestResourceEditor());
disposables.add(EditorRegistry.registerEditor(d1, [new SyncDescriptor(MyResourceEditorInput)]));
let inst = workbenchInstantiationService();
@@ -165,14 +168,20 @@ suite('Workbench EditorPane', () => {
const otherEditor = EditorRegistry.getEditor(inst.createInstance(ResourceEditorInput, URI.file('/fake'), 'fake', '', undefined))!.instantiate(inst);
assert.strictEqual(otherEditor.getId(), 'workbench.editors.textResourceEditor');
disposable.dispose();
disposables.dispose();
});
test('Editor Lookup favors specific class over superclass (match on super class)', function () {
let inst = workbenchInstantiationService();
const disposables = new DisposableStore();
disposables.add(registerTestResourceEditor());
const editor = EditorRegistry.getEditor(inst.createInstance(MyResourceEditorInput, URI.file('/fake'), 'fake', '', undefined))!.instantiate(inst);
assert.strictEqual('workbench.editors.textResourceEditor', editor.getId());
disposables.dispose();
});
test('Editor Input Factory', function () {
@@ -209,12 +218,12 @@ suite('Workbench EditorPane', () => {
memento.saveEditorState(testGroup0, URI.file('/A'), { line: 3 });
res = memento.loadEditorState(testGroup0, URI.file('/A'));
assert.ok(res);
assert.equal(res!.line, 3);
assert.strictEqual(res!.line, 3);
memento.saveEditorState(testGroup1, URI.file('/A'), { line: 5 });
res = memento.loadEditorState(testGroup1, URI.file('/A'));
assert.ok(res);
assert.equal(res!.line, 5);
assert.strictEqual(res!.line, 5);
// Ensure capped at 3 elements
memento.saveEditorState(testGroup0, URI.file('/B'), { line: 1 });
@@ -276,15 +285,15 @@ suite('Workbench EditorPane', () => {
assert.ok(!res);
res = memento.loadEditorState(testGroup0, URI.file('/some/folder/file-moved.txt'));
assert.equal(res?.line, 1);
assert.strictEqual(res?.line, 1);
memento.moveEditorState(URI.file('/some/folder'), URI.file('/some/folder-moved'), extUri);
res = memento.loadEditorState(testGroup0, URI.file('/some/folder-moved/file-moved.txt'));
assert.equal(res?.line, 1);
assert.strictEqual(res?.line, 1);
res = memento.loadEditorState(testGroup0, URI.file('/some/folder-moved/file-2.txt'));
assert.equal(res?.line, 2);
assert.strictEqual(res?.line, 2);
});
test('EditoMemento - use with editor input', function () {
@@ -299,7 +308,7 @@ suite('Workbench EditorPane', () => {
super();
}
getTypeId() { return 'testEditorInputForMementoTest'; }
resolve(): Promise<IEditorModel> { return Promise.resolve(null!); }
async resolve(): Promise<IEditorModel | null> { return null; }
matches(other: TestEditorInput): boolean {
return other && this.id === other.id && other instanceof TestEditorInput;
@@ -317,7 +326,7 @@ suite('Workbench EditorPane', () => {
memento.saveEditorState(testGroup0, testInputA, { line: 3 });
res = memento.loadEditorState(testGroup0, testInputA);
assert.ok(res);
assert.equal(res!.line, 3);
assert.strictEqual(res!.line, 3);
// State removed when input gets disposed
testInputA.dispose();
@@ -337,7 +346,7 @@ suite('Workbench EditorPane', () => {
super();
}
getTypeId() { return 'testEditorInputForMementoTest'; }
resolve(): Promise<IEditorModel> { return Promise.resolve(null!); }
async resolve(): Promise<IEditorModel | null> { return null; }
matches(other: TestEditorInput): boolean {
return other && this.id === other.id && other instanceof TestEditorInput;
@@ -355,7 +364,7 @@ suite('Workbench EditorPane', () => {
memento.saveEditorState(testGroup0, testInputA.resource, { line: 3 });
res = memento.loadEditorState(testGroup0, testInputA);
assert.ok(res);
assert.equal(res!.line, 3);
assert.strictEqual(res!.line, 3);
// State not yet removed when input gets disposed
// because we used resource
@@ -371,7 +380,7 @@ suite('Workbench EditorPane', () => {
memento.saveEditorState(testGroup0, testInputB.resource, { line: 3 });
res = memento.loadEditorState(testGroup0, testInputB);
assert.ok(res);
assert.equal(res!.line, 3);
assert.strictEqual(res!.line, 3);
memento.clearEditorStateOnDispose(testInputB.resource, testInputB);

View File

@@ -31,7 +31,7 @@ suite('Resource text editors', () => {
const model = await input.resolve();
assert.ok(model);
assert.equal(snapshotToString(((model as ResourceEditorModel).createSnapshot()!)), 'function test() {}');
assert.strictEqual(snapshotToString(((model as ResourceEditorModel).createSnapshot()!)), 'function test() {}');
});
test('custom mode', async () => {
@@ -46,9 +46,9 @@ suite('Resource text editors', () => {
const model = await input.resolve();
assert.ok(model);
assert.equal(model.textEditorModel.getModeId(), 'resource-input-test');
assert.strictEqual(model.textEditorModel.getModeId(), 'resource-input-test');
input.setMode('text');
assert.equal(model.textEditorModel.getModeId(), PLAINTEXT_MODE_ID);
assert.strictEqual(model.textEditorModel.getModeId(), PLAINTEXT_MODE_ID);
});
});

View File

@@ -4,9 +4,9 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import * as Platform from 'vs/platform/registry/common/platform';
import { Registry } from 'vs/platform/registry/common/platform';
import { ViewletDescriptor, Extensions, Viewlet, ViewletRegistry } from 'vs/workbench/browser/viewlet';
import * as Types from 'vs/base/common/types';
import { isFunction } from 'vs/base/common/types';
suite('Viewlets', () => {
@@ -40,15 +40,15 @@ suite('Viewlets', () => {
});
test('Viewlet extension point and registration', function () {
assert(Types.isFunction(Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).registerViewlet));
assert(Types.isFunction(Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlet));
assert(Types.isFunction(Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlets));
assert(isFunction(Registry.as<ViewletRegistry>(Extensions.Viewlets).registerViewlet));
assert(isFunction(Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlet));
assert(isFunction(Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlets));
let oldCount = Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlets().length;
let oldCount = Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlets().length;
let d = ViewletDescriptor.create(TestViewlet, 'reg-test-id', 'name');
Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).registerViewlet(d);
Registry.as<ViewletRegistry>(Extensions.Viewlets).registerViewlet(d);
assert(d === Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlet('reg-test-id'));
assert.equal(oldCount + 1, Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlets().length);
assert(d === Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlet('reg-test-id'));
assert.strictEqual(oldCount + 1, Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlets().length);
});
});

View File

@@ -3,17 +3,16 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import 'vs/workbench/contrib/files/browser/files.contribution'; // load our contribution into the test
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import * as resources from 'vs/base/common/resources';
import { basename } from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { IEditorInputWithOptions, IEditorIdentifier, IUntitledTextResourceEditorInput, IResourceDiffEditorInput, IEditorInput, IEditorPane, IEditorCloseEvent, IEditorPartOptions, IRevertOptions, GroupIdentifier, EditorInput, EditorOptions, EditorsOrder, IFileEditorInput, IEditorInputFactoryRegistry, IEditorInputFactory, Extensions as EditorExtensions, ISaveOptions, IMoveResult, ITextEditorPane, ITextDiffEditorPane, IVisibleEditorPane, IEditorOpenContext } from 'vs/workbench/common/editor';
import { IEditorInputWithOptions, IEditorIdentifier, IUntitledTextResourceEditorInput, IResourceDiffEditorInput, IEditorInput, IEditorPane, IEditorCloseEvent, IEditorPartOptions, IRevertOptions, GroupIdentifier, EditorInput, EditorOptions, EditorsOrder, IFileEditorInput, IEditorInputFactoryRegistry, IEditorInputFactory, Extensions as EditorExtensions, ISaveOptions, IMoveResult, ITextEditorPane, ITextDiffEditorPane, IVisibleEditorPane, IEditorOpenContext, SideBySideEditorInput } from 'vs/workbench/common/editor';
import { IEditorOpeningEvent, EditorServiceImpl, IEditorGroupView, IEditorGroupsAccessor, IEditorGroupTitleDimensions } from 'vs/workbench/browser/parts/editor/editor';
import { Event, Emitter } from 'vs/base/common/event';
import { IBackupFileService, IResolvedBackup } from 'vs/workbench/services/backup/common/backup';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { IWorkbenchLayoutService, Parts, Position as PartPosition } from 'vs/workbench/services/layout/browser/layoutService';
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
@@ -23,7 +22,7 @@ import { IUntitledTextEditorService, UntitledTextEditorService } from 'vs/workbe
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { ILifecycleService, BeforeShutdownEvent, ShutdownReason, StartupKind, LifecyclePhase, WillShutdownEvent } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { FileOperationEvent, IFileService, IFileStat, IResolveFileResult, FileChangesEvent, IResolveFileOptions, ICreateFileOptions, IFileSystemProvider, FileSystemProviderCapabilities, IFileChange, IWatchOptions, IStat, FileType, FileDeleteOptions, FileOverwriteOptions, FileWriteOptions, FileOpenOptions, IFileStatWithMetadata, IResolveMetadataFileOptions, IWriteFileOptions, IReadFileOptions, IFileContent, IFileStreamContent, FileOperationError, IFileSystemProviderWithFileReadStreamCapability } from 'vs/platform/files/common/files';
import { FileOperationEvent, IFileService, IFileStat, IResolveFileResult, FileChangesEvent, IResolveFileOptions, ICreateFileOptions, IFileSystemProvider, FileSystemProviderCapabilities, IFileChange, IWatchOptions, IStat, FileType, FileDeleteOptions, FileOverwriteOptions, FileWriteOptions, FileOpenOptions, IFileStatWithMetadata, IResolveMetadataFileOptions, IWriteFileOptions, IReadFileOptions, IFileContent, IFileStreamContent, FileOperationError, IFileSystemProviderWithFileReadStreamCapability, FileReadStreamOptions } from 'vs/platform/files/common/files';
import { IModelService } from 'vs/editor/common/services/modelService';
import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
@@ -97,7 +96,7 @@ import { TestDialogService } from 'vs/platform/dialogs/test/common/testDialogSer
import { CodeEditorService } from 'vs/workbench/services/editor/browser/codeEditorService';
import { EditorPart } from 'vs/workbench/browser/parts/editor/editorPart';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { IDiffEditor } from 'vs/editor/common/editorCommon';
import { IDiffEditor, IEditor } from 'vs/editor/common/editorCommon';
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { QuickInputService } from 'vs/workbench/services/quickinput/browser/quickInputService';
import { IListService } from 'vs/platform/list/browser/listService';
@@ -114,24 +113,63 @@ import { EncodingOracle, IEncodingOverride } from 'vs/workbench/services/textfil
import { UTF16le, UTF16be, UTF8_with_bom } from 'vs/workbench/services/textfile/common/encoding';
import { ColorScheme } from 'vs/platform/theme/common/theme';
import { Iterable } from 'vs/base/common/iterator';
import { InMemoryBackupFileService } from 'vs/workbench/services/backup/common/backupFileService';
import { hash } from 'vs/base/common/hash';
import { BrowserBackupFileService } from 'vs/workbench/services/backup/browser/backupFileService';
import { FileService } from 'vs/platform/files/common/fileService';
import { TextResourceEditor } from 'vs/workbench/browser/parts/editor/textResourceEditor';
import { TestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
import { TextFileEditor } from 'vs/workbench/contrib/files/browser/editors/textFileEditor';
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
import { SideBySideEditor } from 'vs/workbench/browser/parts/editor/sideBySideEditor';
import { IEnterWorkspaceResult, IRecent, IRecentlyOpened, IWorkspaceFolderCreationData, IWorkspaceIdentifier, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
export function createFileEditorInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
return instantiationService.createInstance(FileEditorInput, resource, undefined, undefined, undefined, undefined, undefined);
}
Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).registerFileEditorInputFactory({
createFileEditorInput: (resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredMode, instantiationService): IFileEditorInput => {
return instantiationService.createInstance(FileEditorInput, resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredMode);
},
isFileEditorInput: (obj): obj is IFileEditorInput => {
return obj instanceof FileEditorInput;
}
});
export class TestTextResourceEditor extends TextResourceEditor {
protected createEditorControl(parent: HTMLElement, configuration: any): IEditor {
return this.instantiationService.createInstance(TestCodeEditor, parent, configuration, {});
}
}
export class TestTextFileEditor extends TextFileEditor {
protected createEditorControl(parent: HTMLElement, configuration: any): IEditor {
return this.instantiationService.createInstance(TestCodeEditor, parent, configuration, {});
}
}
export interface ITestInstantiationService extends IInstantiationService {
stub<T>(service: ServiceIdentifier<T>, ctor: any): T;
}
export function workbenchInstantiationService(overrides?: {
textFileService?: (instantiationService: IInstantiationService) => ITextFileService
pathService?: (instantiationService: IInstantiationService) => IPathService,
editorService?: (instantiationService: IInstantiationService) => IEditorService,
contextKeyService?: (instantiationService: IInstantiationService) => IContextKeyService,
}): ITestInstantiationService {
export function workbenchInstantiationService(
overrides?: {
textFileService?: (instantiationService: IInstantiationService) => ITextFileService;
pathService?: (instantiationService: IInstantiationService) => IPathService,
editorService?: (instantiationService: IInstantiationService) => IEditorService,
contextKeyService?: (instantiationService: IInstantiationService) => IContextKeyService,
},
disposables: DisposableStore = new DisposableStore()
): ITestInstantiationService {
const instantiationService = new TestInstantiationService(new ServiceCollection([ILifecycleService, new TestLifecycleService()]));
instantiationService.stub(IWorkingCopyService, new TestWorkingCopyService());
instantiationService.stub(IWorkingCopyService, disposables.add(new TestWorkingCopyService()));
instantiationService.stub(IEnvironmentService, TestEnvironmentService);
const contextKeyService = overrides?.contextKeyService ? overrides.contextKeyService(instantiationService) : instantiationService.createInstance(MockContextKeyService);
instantiationService.stub(IContextKeyService, contextKeyService);
@@ -140,10 +178,10 @@ export function workbenchInstantiationService(overrides?: {
instantiationService.stub(IWorkspaceContextService, workspaceContextService);
const configService = new TestConfigurationService();
instantiationService.stub(IConfigurationService, configService);
instantiationService.stub(IFilesConfigurationService, new TestFilesConfigurationService(contextKeyService, configService));
instantiationService.stub(IFilesConfigurationService, disposables.add(new TestFilesConfigurationService(contextKeyService, configService)));
instantiationService.stub(ITextResourceConfigurationService, new TestTextResourceConfigurationService(configService));
instantiationService.stub(IUntitledTextEditorService, instantiationService.createInstance(UntitledTextEditorService));
instantiationService.stub(IStorageService, new TestStorageService());
instantiationService.stub(IUntitledTextEditorService, disposables.add(instantiationService.createInstance(UntitledTextEditorService)));
instantiationService.stub(IStorageService, disposables.add(new TestStorageService()));
instantiationService.stub(IPathService, overrides?.pathService ? overrides.pathService(instantiationService) : new TestPathService());
const layoutService = new TestLayoutService();
instantiationService.stub(IWorkbenchLayoutService, layoutService);
@@ -151,39 +189,40 @@ export function workbenchInstantiationService(overrides?: {
const accessibilityService = new TestAccessibilityService();
instantiationService.stub(IAccessibilityService, accessibilityService);
instantiationService.stub(IFileDialogService, instantiationService.createInstance(TestFileDialogService));
instantiationService.stub(IModeService, instantiationService.createInstance(ModeServiceImpl));
instantiationService.stub(IModeService, disposables.add(instantiationService.createInstance(ModeServiceImpl)));
instantiationService.stub(IHistoryService, new TestHistoryService());
instantiationService.stub(ITextResourcePropertiesService, new TestTextResourcePropertiesService(configService));
instantiationService.stub(IUndoRedoService, instantiationService.createInstance(UndoRedoService));
const themeService = new TestThemeService();
instantiationService.stub(IThemeService, themeService);
instantiationService.stub(IModelService, instantiationService.createInstance(ModelServiceImpl));
instantiationService.stub(IModelService, disposables.add(instantiationService.createInstance(ModelServiceImpl)));
const fileService = new TestFileService();
instantiationService.stub(IFileService, fileService);
instantiationService.stub(IUriIdentityService, new UriIdentityService(fileService));
instantiationService.stub(IBackupFileService, new TestBackupFileService());
instantiationService.stub(ITelemetryService, NullTelemetryService);
instantiationService.stub(INotificationService, new TestNotificationService());
instantiationService.stub(IUntitledTextEditorService, instantiationService.createInstance(UntitledTextEditorService));
instantiationService.stub(IUntitledTextEditorService, disposables.add(instantiationService.createInstance(UntitledTextEditorService)));
instantiationService.stub(IMenuService, new TestMenuService());
const keybindingService = new MockKeybindingService();
instantiationService.stub(IKeybindingService, keybindingService);
instantiationService.stub(IDecorationsService, new TestDecorationsService());
instantiationService.stub(IExtensionService, new TestExtensionService());
instantiationService.stub(IWorkingCopyFileService, instantiationService.createInstance(WorkingCopyFileService));
instantiationService.stub(ITextFileService, overrides?.textFileService ? overrides.textFileService(instantiationService) : <ITextFileService>instantiationService.createInstance(TestTextFileService));
instantiationService.stub(IWorkingCopyFileService, disposables.add(instantiationService.createInstance(WorkingCopyFileService)));
instantiationService.stub(ITextFileService, overrides?.textFileService ? overrides.textFileService(instantiationService) : disposables.add(<ITextFileService>instantiationService.createInstance(TestTextFileService)));
instantiationService.stub(IHostService, <IHostService>instantiationService.createInstance(TestHostService));
instantiationService.stub(ITextModelService, <ITextModelService>instantiationService.createInstance(TextModelResolverService));
instantiationService.stub(ITextModelService, <ITextModelService>disposables.add(instantiationService.createInstance(TextModelResolverService)));
instantiationService.stub(ILogService, new NullLogService());
const editorGroupService = new TestEditorGroupsService([new TestEditorGroupView(0)]);
instantiationService.stub(IEditorGroupsService, editorGroupService);
instantiationService.stub(ILabelService, <ILabelService>instantiationService.createInstance(LabelService));
instantiationService.stub(ILabelService, <ILabelService>disposables.add(instantiationService.createInstance(LabelService)));
const editorService = overrides?.editorService ? overrides.editorService(instantiationService) : new TestEditorService(editorGroupService);
instantiationService.stub(IEditorService, editorService);
instantiationService.stub(ICodeEditorService, new CodeEditorService(editorService, themeService));
instantiationService.stub(ICodeEditorService, disposables.add(new CodeEditorService(editorService, themeService, configService)));
instantiationService.stub(IViewletService, new TestViewletService());
instantiationService.stub(IListService, new TestListService());
instantiationService.stub(IQuickInputService, new QuickInputService(configService, instantiationService, keybindingService, contextKeyService, themeService, accessibilityService, layoutService));
instantiationService.stub(IQuickInputService, disposables.add(new QuickInputService(configService, instantiationService, keybindingService, contextKeyService, themeService, accessibilityService, layoutService)));
instantiationService.stub(IWorkspacesService, new TestWorkspacesService());
return instantiationService;
}
@@ -372,7 +411,7 @@ export class TestHistoryService implements IHistoryService {
forward(): void { }
back(): void { }
last(): void { }
remove(_input: IEditorInput | IResourceEditorInput): void { }
removeFromHistory(_input: IEditorInput | IResourceEditorInput): void { }
clear(): void { }
clearRecentlyOpened(): void { }
getHistory(): ReadonlyArray<IEditorInput | IResourceEditorInput> { return []; }
@@ -432,6 +471,7 @@ export class TestLayoutService implements IWorkbenchLayoutService {
private readonly _onMenubarVisibilityChange = new Emitter<Dimension>();
get onMenubarVisibilityChange(): Event<Dimension> { return this._onMenubarVisibilityChange.event; }
layout(): void { }
isRestored(): boolean { return true; }
hasFocus(_part: Parts): boolean { return false; }
focusPart(_part: Parts): void { }
@@ -446,16 +486,17 @@ export class TestLayoutService implements IWorkbenchLayoutService {
isActivityBarHidden(): boolean { return false; }
setActivityBarHidden(_hidden: boolean): void { }
isSideBarHidden(): boolean { return false; }
setEditorHidden(_hidden: boolean): Promise<void> { return Promise.resolve(); }
setSideBarHidden(_hidden: boolean): Promise<void> { return Promise.resolve(); }
async setEditorHidden(_hidden: boolean): Promise<void> { }
async setSideBarHidden(_hidden: boolean): Promise<void> { }
isPanelHidden(): boolean { return false; }
setPanelHidden(_hidden: boolean): Promise<void> { return Promise.resolve(); }
async setPanelHidden(_hidden: boolean): Promise<void> { }
toggleMaximizedPanel(): void { }
isPanelMaximized(): boolean { return false; }
getMenubarVisibility(): MenuBarVisibility { throw new Error('not implemented'); }
toggleMenuBar(): void { }
getSideBarPosition() { return 0; }
getPanelPosition() { return 0; }
setPanelPosition(_position: PartPosition): Promise<void> { return Promise.resolve(); }
async setPanelPosition(_position: PartPosition): Promise<void> { }
addClass(_clazz: string): void { }
removeClass(_clazz: string): void { }
getMaximumEditorDimensions(): Dimension { throw new Error('not implemented'); }
@@ -501,7 +542,7 @@ export class TestViewletService implements IViewletService {
export class TestPanelService implements IPanelService {
declare readonly _serviceBrand: undefined;
onDidPanelOpen = new Emitter<{ panel: IPanel, focus: boolean }>().event;
onDidPanelOpen = new Emitter<{ panel: IPanel, focus: boolean; }>().event;
onDidPanelClose = new Emitter<IPanel>().event;
async openPanel(id?: string, focus?: boolean): Promise<undefined> { return undefined; }
@@ -521,7 +562,7 @@ export class TestViewsService implements IViewsService {
declare readonly _serviceBrand: undefined;
onDidChangeViewContainerVisibility = new Emitter<{ id: string; visible: boolean; location: ViewContainerLocation }>().event;
onDidChangeViewContainerVisibility = new Emitter<{ id: string; visible: boolean; location: ViewContainerLocation; }>().event;
isViewContainerVisible(id: string): boolean { return true; }
getVisibleViewContainer(): ViewContainer | null { return null; }
openViewContainer(id: string, focus?: boolean): Promise<IPaneComposite | null> { return Promise.resolve(null); }
@@ -567,8 +608,8 @@ export class TestEditorGroupsService implements IEditorGroupsService {
findGroup(_scope: IFindGroupScope, _source?: number | IEditorGroup, _wrap?: boolean): IEditorGroup { throw new Error('not implemented'); }
activateGroup(_group: number | IEditorGroup): IEditorGroup { throw new Error('not implemented'); }
restoreGroup(_group: number | IEditorGroup): IEditorGroup { throw new Error('not implemented'); }
getSize(_group: number | IEditorGroup): { width: number, height: number } { return { width: 100, height: 100 }; }
setSize(_group: number | IEditorGroup, _size: { width: number, height: number }): void { }
getSize(_group: number | IEditorGroup): { width: number, height: number; } { return { width: 100, height: 100 }; }
setSize(_group: number | IEditorGroup, _size: { width: number, height: number; }): void { }
arrangeGroups(_arrangement: GroupsArrangement): void { }
applyLayout(_layout: EditorGroupLayout): void { }
setGroupOrientation(_orientation: GroupOrientation): void { }
@@ -631,10 +672,10 @@ export class TestEditorGroupView implements IEditorGroupView {
isActive(_editor: IEditorInput): boolean { return false; }
moveEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: IMoveEditorOptions): void { }
copyEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: ICopyEditorOptions): void { }
closeEditor(_editor?: IEditorInput, options?: ICloseEditorOptions): Promise<void> { return Promise.resolve(); }
closeEditors(_editors: IEditorInput[] | ICloseEditorsFilter, options?: ICloseEditorOptions): Promise<void> { return Promise.resolve(); }
closeAllEditors(options?: ICloseAllEditorsOptions): Promise<void> { return Promise.resolve(); }
replaceEditors(_editors: IEditorReplacement[]): Promise<void> { return Promise.resolve(); }
async closeEditor(_editor?: IEditorInput, options?: ICloseEditorOptions): Promise<void> { }
async closeEditors(_editors: IEditorInput[] | ICloseEditorsFilter, options?: ICloseEditorOptions): Promise<void> { }
async closeAllEditors(options?: ICloseAllEditorsOptions): Promise<void> { }
async replaceEditors(_editors: IEditorReplacement[]): Promise<void> { }
pinEditor(_editor?: IEditorInput): void { }
stickEditor(editor?: IEditorInput | undefined): void { }
unstickEditor(editor?: IEditorInput | undefined): void { }
@@ -700,6 +741,7 @@ export class TestEditorService implements EditorServiceImpl {
constructor(private editorGroupService?: IEditorGroupsService) { }
getEditors() { return []; }
findEditors() { return []; }
getEditorOverrides(resource: URI, options: IEditorOptions | undefined, group: IEditorGroup | undefined): [IOpenEditorOverrideHandler, IOpenEditorOverrideEntry][] { return []; }
overrideOpenEditor(_handler: IOpenEditorOverrideHandler): IDisposable { return toDisposable(() => undefined); }
registerCustomEditorViewTypesHandler(source: string, handler: ICustomEditorViewTypesHandler): IDisposable {
@@ -726,7 +768,7 @@ export class TestEditorService implements EditorServiceImpl {
saveAll(options?: ISaveEditorsOptions): Promise<boolean> { throw new Error('Method not implemented.'); }
revert(editors: IEditorIdentifier[], options?: IRevertOptions): Promise<boolean> { throw new Error('Method not implemented.'); }
revertAll(options?: IRevertAllEditorsOptions): Promise<boolean> { throw new Error('Method not implemented.'); }
whenClosed(editors: IResourceEditorInput[], options?: { waitForSaved: boolean }): Promise<void> { throw new Error('Method not implemented.'); }
whenClosed(editors: IResourceEditorInput[], options?: { waitForSaved: boolean; }): Promise<void> { throw new Error('Method not implemented.'); }
}
export class TestFileService implements IFileService {
@@ -762,11 +804,11 @@ export class TestFileService implements IFileService {
isFile: true,
isDirectory: false,
isSymbolicLink: false,
name: resources.basename(resource)
name: basename(resource)
});
}
async resolveAll(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Promise<IResolveFileResult[]> {
async resolveAll(toResolve: { resource: URI, options?: IResolveFileOptions; }[]): Promise<IResolveFileResult[]> {
const stats = await Promise.all(toResolve.map(resourceAndOption => this.resolve(resourceAndOption.resource, resourceAndOption.options)));
return stats.map(stat => ({ stat, success: true }));
@@ -784,7 +826,7 @@ export class TestFileService implements IFileService {
encoding: 'utf8',
mtime: Date.now(),
ctime: Date.now(),
name: resources.basename(resource),
name: basename(resource),
size: 1
});
}
@@ -813,7 +855,7 @@ export class TestFileService implements IFileService {
mtime: Date.now(),
ctime: Date.now(),
size: 1,
name: resources.basename(resource)
name: basename(resource)
});
}
@@ -835,7 +877,7 @@ export class TestFileService implements IFileService {
isFile: true,
isDirectory: false,
isSymbolicLink: false,
name: resources.basename(resource)
name: basename(resource)
});
}
@@ -870,7 +912,7 @@ export class TestFileService implements IFileService {
return false;
}
del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean }): Promise<void> { return Promise.resolve(); }
async del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean; }): Promise<void> { }
readonly watches: URI[] = [];
watch(_resource: URI): IDisposable {
@@ -888,27 +930,78 @@ export class TestFileService implements IFileService {
async canDelete(resource: URI, options?: { useTrash?: boolean | undefined; recursive?: boolean | undefined; } | undefined): Promise<Error | true> { return true; }
}
export class TestBackupFileService implements IBackupFileService {
declare readonly _serviceBrand: undefined;
export class TestBackupFileService extends InMemoryBackupFileService {
constructor() {
super(resource => String(hash(resource.path)));
}
hasBackups(): Promise<boolean> { return Promise.resolve(false); }
hasBackup(_resource: URI): Promise<boolean> { return Promise.resolve(false); }
hasBackupSync(resource: URI, versionId?: number): boolean { return false; }
registerResourceForBackup(_resource: URI): Promise<void> { return Promise.resolve(); }
deregisterResourceForBackup(_resource: URI): Promise<void> { return Promise.resolve(); }
backup<T extends object>(_resource: URI, _content?: ITextSnapshot, versionId?: number, meta?: T): Promise<void> { return Promise.resolve(); }
getBackups(): Promise<URI[]> { return Promise.resolve([]); }
resolve<T extends object>(_backup: URI): Promise<IResolvedBackup<T> | undefined> { return Promise.resolve(undefined); }
discardBackup(_resource: URI): Promise<void> { return Promise.resolve(); }
discardBackups(): Promise<void> { return Promise.resolve(); }
parseBackupContent(textBufferFactory: ITextBufferFactory): string {
const textBuffer = textBufferFactory.create(DefaultEndOfLine.LF);
const textBuffer = textBufferFactory.create(DefaultEndOfLine.LF).textBuffer;
const lineCount = textBuffer.getLineCount();
const range = new Range(1, 1, lineCount, textBuffer.getLineLength(lineCount) + 1);
return textBuffer.getValueInRange(range, EndOfLinePreference.TextDefined);
}
}
export class InMemoryTestBackupFileService extends BrowserBackupFileService {
readonly fileService: IFileService;
private backupResourceJoiners: Function[];
private discardBackupJoiners: Function[];
discardedBackups: URI[];
constructor() {
const environmentService = TestEnvironmentService;
const logService = new NullLogService();
const fileService = new FileService(logService);
fileService.registerProvider(Schemas.file, new InMemoryFileSystemProvider());
fileService.registerProvider(Schemas.userData, new InMemoryFileSystemProvider());
super(new TestContextService(TestWorkspace), environmentService, fileService, logService);
this.fileService = fileService;
this.backupResourceJoiners = [];
this.discardBackupJoiners = [];
this.discardedBackups = [];
}
joinBackupResource(): Promise<void> {
return new Promise(resolve => this.backupResourceJoiners.push(resolve));
}
joinDiscardBackup(): Promise<void> {
return new Promise(resolve => this.discardBackupJoiners.push(resolve));
}
async backup(resource: URI, content?: ITextSnapshot, versionId?: number, meta?: any, token?: CancellationToken): Promise<void> {
await super.backup(resource, content, versionId, meta, token);
while (this.backupResourceJoiners.length) {
this.backupResourceJoiners.pop()!();
}
}
async discardBackup(resource: URI): Promise<void> {
await super.discardBackup(resource);
this.discardedBackups.push(resource);
while (this.discardBackupJoiners.length) {
this.discardBackupJoiners.pop()!();
}
}
async getBackupContents(resource: URI): Promise<string> {
const backupResource = this.toBackupResource(resource);
const fileContents = await this.fileService.readFile(backupResource);
return fileContents.value.toString();
}
}
export class TestLifecycleService implements ILifecycleService {
declare readonly _serviceBrand: undefined;
@@ -925,7 +1018,7 @@ export class TestLifecycleService implements ILifecycleService {
private readonly _onShutdown = new Emitter<void>();
get onShutdown(): Event<void> { return this._onShutdown.event; }
when(): Promise<void> { return Promise.resolve(); }
async when(): Promise<void> { }
fireShutdown(reason = ShutdownReason.QUIT): void {
this._onWillShutdown.fire({
@@ -993,6 +1086,8 @@ export class RemoteFileSystemProvider implements IFileSystemProvider {
read(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> { return this.diskFileSystemProvider.read!(fd, pos, data, offset, length); }
write(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> { return this.diskFileSystemProvider.write!(fd, pos, data, offset, length); }
readFileStream(resource: URI, opts: FileReadStreamOptions, token: CancellationToken): ReadableStreamEvents<Uint8Array> { return this.diskFileSystemProvider.readFileStream!(this.toFileResource(resource), opts, token); }
private toFileResource(resource: URI): URI { return resource.with({ scheme: Schemas.file, authority: '' }); }
}
@@ -1051,7 +1146,7 @@ export class TestHostService implements IHostService {
async reload(): Promise<void> { }
async close(): Promise<void> { }
async focus(options?: { force: boolean }): Promise<void> { }
async focus(options?: { force: boolean; }): Promise<void> { }
async openWindow(arg1?: IOpenEmptyWindowOptions | IWindowOpenable[], arg2?: IOpenWindowOptions): Promise<void> { }
@@ -1153,6 +1248,56 @@ export function registerTestEditor(id: string, inputs: SyncDescriptor<EditorInpu
return disposables;
}
export function registerTestFileEditor(): IDisposable {
const disposables = new DisposableStore();
disposables.add(Registry.as<IEditorRegistry>(Extensions.Editors).registerEditor(
EditorDescriptor.create(
TestTextFileEditor,
TestTextFileEditor.ID,
'Text File Editor'
),
[new SyncDescriptor<EditorInput>(FileEditorInput)]
));
return disposables;
}
export function registerTestResourceEditor(): IDisposable {
const disposables = new DisposableStore();
disposables.add(Registry.as<IEditorRegistry>(Extensions.Editors).registerEditor(
EditorDescriptor.create(
TestTextResourceEditor,
TestTextResourceEditor.ID,
'Text Editor'
),
[
new SyncDescriptor<EditorInput>(UntitledTextEditorInput),
new SyncDescriptor<EditorInput>(ResourceEditorInput)
]
));
return disposables;
}
export function registerTestSideBySideEditor(): IDisposable {
const disposables = new DisposableStore();
disposables.add(Registry.as<IEditorRegistry>(Extensions.Editors).registerEditor(
EditorDescriptor.create(
SideBySideEditor,
SideBySideEditor.ID,
'Text Editor'
),
[
new SyncDescriptor(SideBySideEditorInput)
]
));
return disposables;
}
export class TestFileEditorInput extends EditorInput implements IFileEditorInput {
readonly preferredResource = this.resource;
@@ -1274,3 +1419,19 @@ export class TestTextFileEditorModelManager extends TextFileEditorModelManager {
return super.remove(resource);
}
}
export class TestWorkspacesService implements IWorkspacesService {
_serviceBrand: undefined;
onRecentlyOpenedChange = Event.None;
async createUntitledWorkspace(folders?: IWorkspaceFolderCreationData[], remoteAuthority?: string): Promise<IWorkspaceIdentifier> { throw new Error('Method not implemented.'); }
async deleteUntitledWorkspace(workspace: IWorkspaceIdentifier): Promise<void> { }
async addRecentlyOpened(recents: IRecent[]): Promise<void> { }
async removeRecentlyOpened(workspaces: URI[]): Promise<void> { }
async clearRecentlyOpened(): Promise<void> { }
async getRecentlyOpened(): Promise<IRecentlyOpened> { return { files: [], workspaces: [] }; }
async getDirtyWorkspaces(): Promise<(URI | IWorkspaceIdentifier)[]> { return []; }
async enterWorkspace(path: URI): Promise<IEnterWorkspaceResult | null> { throw new Error('Method not implemented.'); }
async getWorkspaceIdentifier(workspacePath: URI): Promise<IWorkspaceIdentifier> { throw new Error('Method not implemented.'); }
}

View File

@@ -1,136 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { IFullSemanticTokensDto, IDeltaSemanticTokensDto, encodeSemanticTokensDto, ISemanticTokensDto, decodeSemanticTokensDto } from 'vs/workbench/api/common/shared/semanticTokensDto';
import { VSBuffer } from 'vs/base/common/buffer';
suite('SemanticTokensDto', () => {
function toArr(arr: Uint32Array): number[] {
const result: number[] = [];
for (let i = 0, len = arr.length; i < len; i++) {
result[i] = arr[i];
}
return result;
}
function assertEqualFull(actual: IFullSemanticTokensDto, expected: IFullSemanticTokensDto): void {
const convert = (dto: IFullSemanticTokensDto) => {
return {
id: dto.id,
type: dto.type,
data: toArr(dto.data)
};
};
assert.deepEqual(convert(actual), convert(expected));
}
function assertEqualDelta(actual: IDeltaSemanticTokensDto, expected: IDeltaSemanticTokensDto): void {
const convertOne = (delta: { start: number; deleteCount: number; data?: Uint32Array; }) => {
if (!delta.data) {
return delta;
}
return {
start: delta.start,
deleteCount: delta.deleteCount,
data: toArr(delta.data)
};
};
const convert = (dto: IDeltaSemanticTokensDto) => {
return {
id: dto.id,
type: dto.type,
deltas: dto.deltas.map(convertOne)
};
};
assert.deepEqual(convert(actual), convert(expected));
}
function testRoundTrip(value: ISemanticTokensDto): void {
const decoded = decodeSemanticTokensDto(encodeSemanticTokensDto(value));
if (value.type === 'full' && decoded.type === 'full') {
assertEqualFull(decoded, value);
} else if (value.type === 'delta' && decoded.type === 'delta') {
assertEqualDelta(decoded, value);
} else {
assert.fail('wrong type');
}
}
test('full encoding', () => {
testRoundTrip({
id: 12,
type: 'full',
data: new Uint32Array([(1 << 24) + (2 << 16) + (3 << 8) + 4])
});
});
test('delta encoding', () => {
testRoundTrip({
id: 12,
type: 'delta',
deltas: [{
start: 0,
deleteCount: 4,
data: undefined
}, {
start: 15,
deleteCount: 0,
data: new Uint32Array([(1 << 24) + (2 << 16) + (3 << 8) + 4])
}, {
start: 27,
deleteCount: 5,
data: new Uint32Array([(1 << 24) + (2 << 16) + (3 << 8) + 4, 1, 2, 3, 4, 5, 6, 7, 8, 9])
}]
});
});
test('partial array buffer', () => {
const sharedArr = new Uint32Array([
(1 << 24) + (2 << 16) + (3 << 8) + 4,
1, 2, 3, 4, 5, (1 << 24) + (2 << 16) + (3 << 8) + 4
]);
testRoundTrip({
id: 12,
type: 'delta',
deltas: [{
start: 0,
deleteCount: 4,
data: sharedArr.subarray(0, 1)
}, {
start: 15,
deleteCount: 0,
data: sharedArr.subarray(1, sharedArr.length)
}]
});
});
test('issue #94521: unusual backing array buffer', () => {
function wrapAndSliceUint8Arry(buff: Uint8Array, prefixLength: number, suffixLength: number): Uint8Array {
const wrapped = new Uint8Array(prefixLength + buff.byteLength + suffixLength);
wrapped.set(buff, prefixLength);
return wrapped.subarray(prefixLength, prefixLength + buff.byteLength);
}
function wrapAndSlice(buff: VSBuffer, prefixLength: number, suffixLength: number): VSBuffer {
return VSBuffer.wrap(wrapAndSliceUint8Arry(buff.buffer, prefixLength, suffixLength));
}
const dto: ISemanticTokensDto = {
id: 5,
type: 'full',
data: new Uint32Array([1, 2, 3, 4, 5])
};
const encoded = encodeSemanticTokensDto(dto);
// with misaligned prefix and misaligned suffix
assertEqualFull(<IFullSemanticTokensDto>decodeSemanticTokensDto(wrapAndSlice(encoded, 1, 1)), dto);
// with misaligned prefix and aligned suffix
assertEqualFull(<IFullSemanticTokensDto>decodeSemanticTokensDto(wrapAndSlice(encoded, 1, 4)), dto);
// with aligned prefix and misaligned suffix
assertEqualFull(<IFullSemanticTokensDto>decodeSemanticTokensDto(wrapAndSlice(encoded, 4, 1)), dto);
// with aligned prefix and aligned suffix
assertEqualFull(<IFullSemanticTokensDto>decodeSemanticTokensDto(wrapAndSlice(encoded, 4, 4)), dto);
});
});

View File

@@ -23,7 +23,7 @@ suite('Memento', () => {
let memento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
memento.foo = [1, 2, 3];
let globalMemento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
assert.deepEqual(globalMemento, memento);
assert.deepStrictEqual(globalMemento, memento);
// Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
@@ -34,18 +34,18 @@ suite('Memento', () => {
// Global
memento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: [1, 2, 3] });
assert.deepStrictEqual(memento, { foo: [1, 2, 3] });
globalMemento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
assert.deepEqual(globalMemento, memento);
assert.deepStrictEqual(globalMemento, memento);
// Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: 'Hello World' });
assert.deepStrictEqual(memento, { foo: 'Hello World' });
// Assert the Mementos are stored properly in storage
assert.deepEqual(JSON.parse(storage.get('memento/memento.test', StorageScope.GLOBAL)!), { foo: [1, 2, 3] });
assert.deepStrictEqual(JSON.parse(storage.get('memento/memento.test', StorageScope.GLOBAL)!), { foo: [1, 2, 3] });
assert.deepEqual(JSON.parse(storage.get('memento/memento.test', StorageScope.WORKSPACE)!), { foo: 'Hello World' });
assert.deepStrictEqual(JSON.parse(storage.get('memento/memento.test', StorageScope.WORKSPACE)!), { foo: 'Hello World' });
// Delete Global
memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
@@ -59,11 +59,11 @@ suite('Memento', () => {
// Global
memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
assert.deepEqual(memento, {});
assert.deepStrictEqual(memento, {});
// Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert.deepEqual(memento, {});
assert.deepStrictEqual(memento, {});
// Assert the Mementos are also removed from storage
assert.strictEqual(storage.get('memento/memento.test', StorageScope.GLOBAL, null!), null);
@@ -87,13 +87,13 @@ suite('Memento', () => {
// Global
memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: [1, 2, 3] });
assert.deepStrictEqual(memento, { foo: [1, 2, 3] });
let globalMemento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
assert.deepEqual(globalMemento, memento);
assert.deepStrictEqual(globalMemento, memento);
// Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: 'Hello World' });
assert.deepStrictEqual(memento, { foo: 'Hello World' });
// Global
memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
@@ -108,13 +108,13 @@ suite('Memento', () => {
// Global
memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: [4, 5, 6] });
assert.deepStrictEqual(memento, { foo: [4, 5, 6] });
globalMemento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
assert.deepEqual(globalMemento, memento);
assert.deepStrictEqual(globalMemento, memento);
// Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: 'World Hello' });
assert.deepStrictEqual(memento, { foo: 'World Hello' });
// Delete Global
memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
@@ -128,11 +128,11 @@ suite('Memento', () => {
// Global
memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
assert.deepEqual(memento, {});
assert.deepStrictEqual(memento, {});
// Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert.deepEqual(memento, {});
assert.deepStrictEqual(memento, {});
});
test('Save and Load - 2 Components with same id', () => {
@@ -160,20 +160,20 @@ suite('Memento', () => {
// Global
memento = myMemento.getMemento(context!, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: [1, 2, 3], bar: [1, 2, 3] });
assert.deepStrictEqual(memento, { foo: [1, 2, 3], bar: [1, 2, 3] });
let globalMemento = myMemento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
assert.deepEqual(globalMemento, memento);
assert.deepStrictEqual(globalMemento, memento);
memento = myMemento2.getMemento(context!, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: [1, 2, 3], bar: [1, 2, 3] });
assert.deepStrictEqual(memento, { foo: [1, 2, 3], bar: [1, 2, 3] });
globalMemento = myMemento2.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
assert.deepEqual(globalMemento, memento);
assert.deepStrictEqual(globalMemento, memento);
// Workspace
memento = myMemento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: 'Hello World', bar: 'Hello World' });
assert.deepStrictEqual(memento, { foo: 'Hello World', bar: 'Hello World' });
memento = myMemento2.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
assert.deepEqual(memento, { foo: 'Hello World', bar: 'Hello World' });
assert.deepStrictEqual(memento, { foo: 'Hello World', bar: 'Hello World' });
});
});

View File

@@ -25,24 +25,24 @@ suite('Notifications', () => {
let item5 = NotificationViewItem.create({ severity: Severity.Error, message: 'Error Message', actions: { primary: [new Action('id', 'label')] } })!;
let item6 = NotificationViewItem.create({ severity: Severity.Error, message: 'Error Message', actions: { primary: [new Action('id', 'label')] }, progress: { infinite: true } })!;
assert.equal(item1.equals(item1), true);
assert.equal(item2.equals(item2), true);
assert.equal(item3.equals(item3), true);
assert.equal(item4.equals(item4), true);
assert.equal(item5.equals(item5), true);
assert.strictEqual(item1.equals(item1), true);
assert.strictEqual(item2.equals(item2), true);
assert.strictEqual(item3.equals(item3), true);
assert.strictEqual(item4.equals(item4), true);
assert.strictEqual(item5.equals(item5), true);
assert.equal(item1.equals(item2), true);
assert.equal(item1.equals(item3), false);
assert.equal(item1.equals(item4), false);
assert.equal(item1.equals(item5), false);
assert.strictEqual(item1.equals(item2), true);
assert.strictEqual(item1.equals(item3), false);
assert.strictEqual(item1.equals(item4), false);
assert.strictEqual(item1.equals(item5), false);
// Progress
assert.equal(item1.hasProgress, false);
assert.equal(item6.hasProgress, true);
assert.strictEqual(item1.hasProgress, false);
assert.strictEqual(item6.hasProgress, true);
// Message Box
assert.equal(item5.canCollapse, false);
assert.equal(item5.expanded, true);
assert.strictEqual(item5.canCollapse, false);
assert.strictEqual(item5.expanded, true);
// Events
let called = 0;
@@ -55,7 +55,7 @@ suite('Notifications', () => {
item1.collapse();
item1.collapse();
assert.equal(called, 2);
assert.strictEqual(called, 2);
called = 0;
item1.onDidChangeContent(e => {
@@ -67,7 +67,7 @@ suite('Notifications', () => {
item1.progress.infinite();
item1.progress.done();
assert.equal(called, 2);
assert.strictEqual(called, 2);
called = 0;
item1.onDidChangeContent(e => {
@@ -96,7 +96,7 @@ suite('Notifications', () => {
item1.updateActions({ primary: [new Action('id2', 'label')] });
assert.equal(called, 1);
assert.strictEqual(called, 1);
called = 0;
item1.onDidChangeVisibility(e => {
@@ -107,7 +107,7 @@ suite('Notifications', () => {
item1.updateVisibility(false);
item1.updateVisibility(false);
assert.equal(called, 2);
assert.strictEqual(called, 2);
called = 0;
item1.onDidClose(() => {
@@ -115,24 +115,24 @@ suite('Notifications', () => {
});
item1.close();
assert.equal(called, 1);
assert.strictEqual(called, 1);
// Error with Action
let item7 = NotificationViewItem.create({ severity: Severity.Error, message: createErrorWithActions('Hello Error', { actions: [new Action('id', 'label')] }) })!;
assert.equal(item7.actions!.primary!.length, 1);
assert.strictEqual(item7.actions!.primary!.length, 1);
// Filter
let item8 = NotificationViewItem.create({ severity: Severity.Error, message: 'Error Message' }, NotificationsFilter.SILENT)!;
assert.equal(item8.silent, true);
assert.strictEqual(item8.silent, true);
let item9 = NotificationViewItem.create({ severity: Severity.Error, message: 'Error Message' }, NotificationsFilter.OFF)!;
assert.equal(item9.silent, false);
assert.strictEqual(item9.silent, false);
let item10 = NotificationViewItem.create({ severity: Severity.Error, message: 'Error Message' }, NotificationsFilter.ERROR)!;
assert.equal(item10.silent, false);
assert.strictEqual(item10.silent, false);
let item11 = NotificationViewItem.create({ severity: Severity.Warning, message: 'Error Message' }, NotificationsFilter.ERROR)!;
assert.equal(item11.silent, true);
assert.strictEqual(item11.silent, true);
});
test('Model', () => {
@@ -154,40 +154,40 @@ suite('Notifications', () => {
let item3: INotification = { severity: Severity.Info, message: 'Info Message' };
let item1Handle = model.addNotification(item1);
assert.equal(lastNotificationEvent.item.severity, item1.severity);
assert.equal(lastNotificationEvent.item.message.linkedText.toString(), item1.message);
assert.equal(lastNotificationEvent.index, 0);
assert.equal(lastNotificationEvent.kind, NotificationChangeType.ADD);
assert.strictEqual(lastNotificationEvent.item.severity, item1.severity);
assert.strictEqual(lastNotificationEvent.item.message.linkedText.toString(), item1.message);
assert.strictEqual(lastNotificationEvent.index, 0);
assert.strictEqual(lastNotificationEvent.kind, NotificationChangeType.ADD);
item1Handle.updateMessage('Error Message');
assert.equal(lastNotificationEvent.kind, NotificationChangeType.CHANGE);
assert.equal(lastNotificationEvent.detail, NotificationViewItemContentChangeKind.MESSAGE);
assert.strictEqual(lastNotificationEvent.kind, NotificationChangeType.CHANGE);
assert.strictEqual(lastNotificationEvent.detail, NotificationViewItemContentChangeKind.MESSAGE);
item1Handle.updateSeverity(Severity.Error);
assert.equal(lastNotificationEvent.kind, NotificationChangeType.CHANGE);
assert.equal(lastNotificationEvent.detail, NotificationViewItemContentChangeKind.SEVERITY);
assert.strictEqual(lastNotificationEvent.kind, NotificationChangeType.CHANGE);
assert.strictEqual(lastNotificationEvent.detail, NotificationViewItemContentChangeKind.SEVERITY);
item1Handle.updateActions({ primary: [], secondary: [] });
assert.equal(lastNotificationEvent.kind, NotificationChangeType.CHANGE);
assert.equal(lastNotificationEvent.detail, NotificationViewItemContentChangeKind.ACTIONS);
assert.strictEqual(lastNotificationEvent.kind, NotificationChangeType.CHANGE);
assert.strictEqual(lastNotificationEvent.detail, NotificationViewItemContentChangeKind.ACTIONS);
item1Handle.progress.infinite();
assert.equal(lastNotificationEvent.kind, NotificationChangeType.CHANGE);
assert.equal(lastNotificationEvent.detail, NotificationViewItemContentChangeKind.PROGRESS);
assert.strictEqual(lastNotificationEvent.kind, NotificationChangeType.CHANGE);
assert.strictEqual(lastNotificationEvent.detail, NotificationViewItemContentChangeKind.PROGRESS);
let item2Handle = model.addNotification(item2);
assert.equal(lastNotificationEvent.item.severity, item2.severity);
assert.equal(lastNotificationEvent.item.message.linkedText.toString(), item2.message);
assert.equal(lastNotificationEvent.index, 0);
assert.equal(lastNotificationEvent.kind, NotificationChangeType.ADD);
assert.strictEqual(lastNotificationEvent.item.severity, item2.severity);
assert.strictEqual(lastNotificationEvent.item.message.linkedText.toString(), item2.message);
assert.strictEqual(lastNotificationEvent.index, 0);
assert.strictEqual(lastNotificationEvent.kind, NotificationChangeType.ADD);
model.addNotification(item3);
assert.equal(lastNotificationEvent.item.severity, item3.severity);
assert.equal(lastNotificationEvent.item.message.linkedText.toString(), item3.message);
assert.equal(lastNotificationEvent.index, 0);
assert.equal(lastNotificationEvent.kind, NotificationChangeType.ADD);
assert.strictEqual(lastNotificationEvent.item.severity, item3.severity);
assert.strictEqual(lastNotificationEvent.item.message.linkedText.toString(), item3.message);
assert.strictEqual(lastNotificationEvent.index, 0);
assert.strictEqual(lastNotificationEvent.kind, NotificationChangeType.ADD);
assert.equal(model.notifications.length, 3);
assert.strictEqual(model.notifications.length, 3);
let called = 0;
item1Handle.onDidClose(() => {
@@ -195,48 +195,48 @@ suite('Notifications', () => {
});
item1Handle.close();
assert.equal(called, 1);
assert.equal(model.notifications.length, 2);
assert.equal(lastNotificationEvent.item.severity, item1.severity);
assert.equal(lastNotificationEvent.item.message.linkedText.toString(), item1.message);
assert.equal(lastNotificationEvent.index, 2);
assert.equal(lastNotificationEvent.kind, NotificationChangeType.REMOVE);
assert.strictEqual(called, 1);
assert.strictEqual(model.notifications.length, 2);
assert.strictEqual(lastNotificationEvent.item.severity, item1.severity);
assert.strictEqual(lastNotificationEvent.item.message.linkedText.toString(), item1.message);
assert.strictEqual(lastNotificationEvent.index, 2);
assert.strictEqual(lastNotificationEvent.kind, NotificationChangeType.REMOVE);
model.addNotification(item2Duplicate);
assert.equal(model.notifications.length, 2);
assert.equal(lastNotificationEvent.item.severity, item2Duplicate.severity);
assert.equal(lastNotificationEvent.item.message.linkedText.toString(), item2Duplicate.message);
assert.equal(lastNotificationEvent.index, 0);
assert.equal(lastNotificationEvent.kind, NotificationChangeType.ADD);
assert.strictEqual(model.notifications.length, 2);
assert.strictEqual(lastNotificationEvent.item.severity, item2Duplicate.severity);
assert.strictEqual(lastNotificationEvent.item.message.linkedText.toString(), item2Duplicate.message);
assert.strictEqual(lastNotificationEvent.index, 0);
assert.strictEqual(lastNotificationEvent.kind, NotificationChangeType.ADD);
item2Handle.close();
assert.equal(model.notifications.length, 1);
assert.equal(lastNotificationEvent.item.severity, item2Duplicate.severity);
assert.equal(lastNotificationEvent.item.message.linkedText.toString(), item2Duplicate.message);
assert.equal(lastNotificationEvent.index, 0);
assert.equal(lastNotificationEvent.kind, NotificationChangeType.REMOVE);
assert.strictEqual(model.notifications.length, 1);
assert.strictEqual(lastNotificationEvent.item.severity, item2Duplicate.severity);
assert.strictEqual(lastNotificationEvent.item.message.linkedText.toString(), item2Duplicate.message);
assert.strictEqual(lastNotificationEvent.index, 0);
assert.strictEqual(lastNotificationEvent.kind, NotificationChangeType.REMOVE);
model.notifications[0].expand();
assert.equal(lastNotificationEvent.item.severity, item3.severity);
assert.equal(lastNotificationEvent.item.message.linkedText.toString(), item3.message);
assert.equal(lastNotificationEvent.index, 0);
assert.equal(lastNotificationEvent.kind, NotificationChangeType.EXPAND_COLLAPSE);
assert.strictEqual(lastNotificationEvent.item.severity, item3.severity);
assert.strictEqual(lastNotificationEvent.item.message.linkedText.toString(), item3.message);
assert.strictEqual(lastNotificationEvent.index, 0);
assert.strictEqual(lastNotificationEvent.kind, NotificationChangeType.EXPAND_COLLAPSE);
const disposable = model.showStatusMessage('Hello World');
assert.equal(model.statusMessage!.message, 'Hello World');
assert.equal(lastStatusMessageEvent.item.message, model.statusMessage!.message);
assert.equal(lastStatusMessageEvent.kind, StatusMessageChangeType.ADD);
assert.strictEqual(model.statusMessage!.message, 'Hello World');
assert.strictEqual(lastStatusMessageEvent.item.message, model.statusMessage!.message);
assert.strictEqual(lastStatusMessageEvent.kind, StatusMessageChangeType.ADD);
disposable.dispose();
assert.ok(!model.statusMessage);
assert.equal(lastStatusMessageEvent.kind, StatusMessageChangeType.REMOVE);
assert.strictEqual(lastStatusMessageEvent.kind, StatusMessageChangeType.REMOVE);
let disposable2 = model.showStatusMessage('Hello World 2');
const disposable3 = model.showStatusMessage('Hello World 3');
assert.equal(model.statusMessage!.message, 'Hello World 3');
assert.strictEqual(model.statusMessage!.message, 'Hello World 3');
disposable2.dispose();
assert.equal(model.statusMessage!.message, 'Hello World 3');
assert.strictEqual(model.statusMessage!.message, 'Hello World 3');
disposable3.dispose();
assert.ok(!model.statusMessage);

View File

@@ -4,22 +4,21 @@
*--------------------------------------------------------------------------------------------*/
import { join } from 'vs/base/common/path';
import * as resources from 'vs/base/common/resources';
import { basename, isEqual, isEqualOrParent } from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri';
import { Event, Emitter } from 'vs/base/common/event';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWorkspaceContextService, IWorkspace, WorkbenchState, IWorkspaceFolder, IWorkspaceFoldersChangeEvent, Workspace } from 'vs/platform/workspace/common/workspace';
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfigurationService';
import { isLinux, isMacintosh } from 'vs/base/common/platform';
import { InMemoryStorageService, WillSaveStateReason } from 'vs/platform/storage/common/storage';
import { WorkingCopyService, IWorkingCopy, IWorkingCopyBackup, WorkingCopyCapabilities } from 'vs/workbench/services/workingCopy/common/workingCopyService';
import { NullExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { IWorkingCopyFileService, IWorkingCopyFileOperationParticipant, WorkingCopyFileEvent } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
import { IWorkingCopyFileService, IWorkingCopyFileOperationParticipant, WorkingCopyFileEvent, IDeleteOperation, ICopyOperation, IMoveOperation, IFileOperationUndoRedoInfo, ICreateFileOperation, ICreateOperation } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
import { IFileStatWithMetadata } from 'vs/platform/files/common/files';
import { VSBuffer, VSBufferReadable, VSBufferReadableStream } from 'vs/base/common/buffer';
import { ISaveOptions, IRevertOptions } from 'vs/workbench/common/editor';
import { CancellationToken } from 'vs/base/common/cancellation';
@@ -105,7 +104,7 @@ export class TestContextService implements IWorkspaceContextService {
isInsideWorkspace(resource: URI): boolean {
if (resource && this.workspace) {
return resources.isEqualOrParent(resource, this.workspace.folders[0].uri);
return isEqualOrParent(resource, this.workspace.folders[0].uri);
}
return false;
@@ -115,8 +114,8 @@ export class TestContextService implements IWorkspaceContextService {
return URI.file(join('C:\\', workspaceRelativePath));
}
isCurrentWorkspace(workspaceIdentifier: ISingleFolderWorkspaceIdentifier | IWorkspaceIdentifier): boolean {
return isSingleFolderWorkspaceIdentifier(workspaceIdentifier) && resources.isEqual(this.workspace.folders[0].uri, workspaceIdentifier);
isCurrentWorkspace(workspaceIdOrFolder: IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI): boolean {
return URI.isUri(workspaceIdOrFolder) && isEqual(this.workspace.folders[0].uri, workspaceIdOrFolder);
}
}
@@ -142,7 +141,7 @@ export class TestWorkingCopy extends Disposable implements IWorkingCopy {
readonly capabilities = WorkingCopyCapabilities.None;
readonly name = resources.basename(this.resource);
readonly name = basename(this.resource);
private dirty = false;
@@ -196,18 +195,18 @@ export class TestWorkingCopyFileService implements IWorkingCopyFileService {
addFileOperationParticipant(participant: IWorkingCopyFileOperationParticipant): IDisposable { return Disposable.None; }
async delete(resources: URI[], options?: { useTrash?: boolean | undefined; recursive?: boolean | undefined; } | undefined): Promise<void> { }
async delete(operations: IDeleteOperation[], undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<void> { }
registerWorkingCopyProvider(provider: (resourceOrFolder: URI) => IWorkingCopy[]): IDisposable { return Disposable.None; }
getDirty(resource: URI): IWorkingCopy[] { return []; }
create(resource: URI, contents?: VSBuffer | VSBufferReadable | VSBufferReadableStream, options?: { overwrite?: boolean | undefined; } | undefined): Promise<IFileStatWithMetadata> { throw new Error('Method not implemented.'); }
createFolder(resource: URI): Promise<IFileStatWithMetadata> { throw new Error('Method not implemented.'); }
create(operations: ICreateFileOperation[], undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata[]> { throw new Error('Method not implemented.'); }
createFolder(operations: ICreateOperation[], undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata[]> { throw new Error('Method not implemented.'); }
move(files: { source: URI; target: URI; }[], options?: { overwrite?: boolean }): Promise<IFileStatWithMetadata[]> { throw new Error('Method not implemented.'); }
move(operations: IMoveOperation[], undoInfo?: IFileOperationUndoRedoInfo): Promise<IFileStatWithMetadata[]> { throw new Error('Method not implemented.'); }
copy(files: { source: URI; target: URI; }[], options?: { overwrite?: boolean }): Promise<IFileStatWithMetadata[]> { throw new Error('Method not implemented.'); }
copy(operations: ICopyOperation[], undoInfo?: IFileOperationUndoRedoInfo, token?: CancellationToken): Promise<IFileStatWithMetadata[]> { throw new Error('Method not implemented.'); }
}
export function mock<T>(): Ctor<T> {

View File

@@ -461,7 +461,7 @@ suite('ExtHostSearch', () => {
]);
});
test.skip('max results = 1', async () => {
test('max results = 1', async () => {
const reportedResults = [
joinPath(rootFolderA, 'file1.ts'),
joinPath(rootFolderA, 'file2.ts'),
@@ -497,7 +497,7 @@ suite('ExtHostSearch', () => {
assert(wasCanceled, 'Expected to be canceled when hitting limit');
});
test.skip('max results = 2', async () => {
test('max results = 2', async () => {
const reportedResults = [
joinPath(rootFolderA, 'file1.ts'),
joinPath(rootFolderA, 'file2.ts'),
@@ -533,7 +533,7 @@ suite('ExtHostSearch', () => {
assert(wasCanceled, 'Expected to be canceled when hitting limit');
});
test.skip('provider returns maxResults exactly', async () => {
test('provider returns maxResults exactly', async () => {
const reportedResults = [
joinPath(rootFolderA, 'file1.ts'),
joinPath(rootFolderA, 'file2.ts'),
@@ -879,7 +879,7 @@ suite('ExtHostSearch', () => {
});
test('basic sibling clause', async () => {
mockPFS.readdir = (_path: string) => {
mockPFS.readdir = (_path: string): any => {
if (_path === rootFolderA.fsPath) {
return Promise.resolve([
'file1.js',
@@ -922,7 +922,7 @@ suite('ExtHostSearch', () => {
});
test('multiroot sibling clause', async () => {
mockPFS.readdir = (_path: string) => {
mockPFS.readdir = (_path: string): any => {
if (_path === joinPath(rootFolderA, 'folder').fsPath) {
return Promise.resolve([
'fileA.scss',

View File

@@ -5,8 +5,8 @@
import { Registry } from 'vs/platform/registry/common/platform';
import { IColorRegistry, Extensions, ColorContribution } from 'vs/platform/theme/common/colorRegistry';
import { asText } from 'vs/platform/request/common/request';
import * as fs from 'fs';
import * as pfs from 'vs/base/node/pfs';
import * as path from 'vs/base/common/path';
import * as assert from 'assert';
@@ -17,7 +17,6 @@ import { TestConfigurationService } from 'vs/platform/configuration/test/common/
import 'vs/workbench/workbench.desktop.main';
import { NullLogService } from 'vs/platform/log/common/log';
interface ColorInfo {
description: string;
offset: number;
@@ -106,7 +105,7 @@ async function getColorsFromExtension(): Promise<{ [id: string]: string }> {
let result: { [id: string]: string } = Object.create(null);
for (let folder of extFolders) {
try {
let packageJSON = JSON.parse((await pfs.readFile(path.join(extPath, folder, 'package.json'))).toString());
let packageJSON = JSON.parse((await fs.promises.readFile(path.join(extPath, folder, 'package.json'))).toString());
let contributes = packageJSON['contributes'];
if (contributes) {
let colors = contributes['colors'];

View File

@@ -52,7 +52,7 @@ export const TestWorkbenchConfiguration: INativeWorkbenchConfiguration = {
appRoot: '',
userEnv: {},
execPath: process.execPath,
perfEntries: [],
perfMarks: [],
colorScheme: { dark: true, highContrast: false },
os: { release: release() },
...parseArgs(process.argv, OPTIONS)
@@ -151,9 +151,6 @@ export class TestSharedProcessService implements ISharedProcessService {
getChannel(channelName: string): any { return undefined; }
registerChannel(channelName: string, channel: any): void { }
async toggleSharedProcessWindow(): Promise<void> { }
async whenSharedProcessReady(): Promise<void> { }
}
export class TestNativeHostService implements INativeHostService {
@@ -225,6 +222,7 @@ export class TestNativeHostService implements INativeHostService {
async exit(code: number): Promise<void> { }
async openDevTools(options?: Electron.OpenDevToolsOptions | undefined): Promise<void> { }
async toggleDevTools(): Promise<void> { }
async toggleSharedProcessWindow(): Promise<void> { }
async resolveProxy(url: string): Promise<string | undefined> { return undefined; }
async readClipboardText(type?: 'selection' | 'clipboard' | undefined): Promise<string> { return ''; }
async writeClipboardData(data: any, type?: 'selection' | 'clipboard' | undefined): Promise<void> { } // {{SQL CARBON EDIT}}

View File

@@ -0,0 +1,266 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import * as platform from 'vs/base/common/platform';
import { findPorts, getSockets, loadConnectionTable, loadListeningPorts } from 'vs/workbench/api/node/extHostTunnelService';
const tcp =
` sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
0: 00000000:0BBA 00000000:0000 0A 00000000:00000000 00:00000000 00000000 1000 0 2335214 1 0000000010173312 100 0 0 10 0
1: 00000000:1AF3 00000000:0000 0A 00000000:00000000 00:00000000 00000000 1000 0 2334514 1 000000008815920b 100 0 0 10 0
2: 0100007F:A9EA 0100007F:1AF3 01 00000000:00000000 00:00000000 00000000 1000 0 2334521 1 00000000a37d44c6 21 4 0 10 -1
3: 0100007F:E8B4 0100007F:98EF 01 00000000:00000000 00:00000000 00000000 1000 0 2334532 1 0000000031b88f06 21 4 0 10 -1
4: 0100007F:866C 0100007F:8783 01 00000000:00000000 00:00000000 00000000 1000 0 2334510 1 00000000cbf670bb 21 4 30 10 -1
5: 0100007F:1AF3 0100007F:A9EA 01 00000000:00000000 00:00000000 00000000 1000 0 2338989 1 0000000000bace62 21 4 1 10 -1
`;
const tcp6 =
` sl local_address remote_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
0: 00000000000000000000000000000000:815B 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 1000 0 2321070 1 00000000c44f3f02 100 0 0 10 0
1: 00000000000000000000000000000000:8783 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 1000 0 2334509 1 000000003915e812 100 0 0 10 0
2: 00000000000000000000000000000000:9907 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 1000 0 2284465 1 00000000f13b9374 100 0 0 10 0
3: 00000000000000000000000000000000:98EF 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 1000 0 2334531 1 00000000184cae9c 100 0 0 10 0
4: 00000000000000000000000000000000:8BCF 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 1000 0 2329890 1 00000000c05a3466 100 0 0 10 0
5: 0000000000000000FFFF00000100007F:8783 0000000000000000FFFF00000100007F:866C 01 00000000:00000000 00:00000000 00000000 1000 0 2334511 1 00000000bf547132 21 4 1 10 -1
6: 0000000000000000FFFF00000100007F:98EF 0000000000000000FFFF00000100007F:E8B4 01 00000000:00000000 00:00000000 00000000 1000 0 2334533 1 0000000039d0bcd2 21 4 1 10 -1
7: 0000000000000000FFFF0000DFD317AC:9907 0000000000000000FFFF000001D017AC:C123 01 0000005A:00000000 01:00000017 00000000 1000 0 2311039 3 0000000067b6c8db 23 5 25 10 52
8: 0000000000000000FFFF0000DFD317AC:9907 0000000000000000FFFF000001D017AC:C124 01 00000000:00000000 00:00000000 00000000 1000 0 2311040 1 00000000230bb017 25 4 30 10 28
9: 0000000000000000FFFF0000DFD317AC:9907 0000000000000000FFFF000001D017AC:C213 01 00000000:00000000 00:00000000 00000000 1000 0 2331501 1 00000000957fcb4a 26 4 30 10 57
10: 0000000000000000FFFF0000DFD317AC:9907 0000000000000000FFFF000001D017AC:C214 01 00000000:00000000 00:00000000 00000000 1000 0 2331500 1 00000000d7f87ceb 25 4 28 10 -1
`;
const procSockets =
`ls: cannot access '/proc/8289/fd/255': No such file or directory
ls: cannot access '/proc/8289/fd/3': No such file or directory
lrwx------ 1 alex alex 64 Dec 8 14:59 /proc/230/fd/3 -> socket:[21862]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/0 -> socket:[2311043]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/1 -> socket:[2311045]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/19 -> socket:[2311040]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/2 -> socket:[2311047]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/20 -> socket:[2314928]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/22 -> socket:[2307042]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/24 -> socket:[2307051]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/25 -> socket:[2307044]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/27 -> socket:[2307046]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/29 -> socket:[2307053]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/3 -> socket:[2311049]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/30 -> socket:[2307048]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/32 -> socket:[2307055]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/33 -> socket:[2307067]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/34 -> socket:[2307057]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/35 -> socket:[2321483]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/37 -> socket:[2321070]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/41 -> socket:[2321485]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/42 -> socket:[2321074]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/43 -> socket:[2321487]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/44 -> socket:[2329890]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/45 -> socket:[2321489]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2504/fd/46 -> socket:[2334509]
lrwx------ 1 alex alex 64 Dec 8 15:17 /proc/2504/fd/47 -> socket:[2334510]
lrwx------ 1 alex alex 64 Dec 8 15:17 /proc/2504/fd/48 -> socket:[2329894]
lrwx------ 1 alex alex 64 Dec 8 15:17 /proc/2504/fd/49 -> socket:[2334511]
lrwx------ 1 alex alex 64 Dec 8 15:17 /proc/2504/fd/50 -> socket:[2334515]
lrwx------ 1 alex alex 64 Dec 8 15:17 /proc/2504/fd/51 -> socket:[2334519]
lrwx------ 1 alex alex 64 Dec 8 15:17 /proc/2504/fd/52 -> socket:[2334518]
lrwx------ 1 alex alex 64 Dec 8 15:17 /proc/2504/fd/53 -> socket:[2334521]
lrwx------ 1 alex alex 64 Dec 8 15:17 /proc/2504/fd/54 -> socket:[2334531]
lrwx------ 1 alex alex 64 Dec 8 15:17 /proc/2504/fd/55 -> socket:[2334532]
lrwx------ 1 alex alex 64 Dec 8 15:17 /proc/2504/fd/56 -> socket:[2334533]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2515/fd/3 -> socket:[2311053]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2719/fd/0 -> socket:[2307043]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2719/fd/1 -> socket:[2307045]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2719/fd/2 -> socket:[2307047]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2719/fd/3 -> socket:[2307049]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2725/fd/0 -> socket:[2307052]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2725/fd/1 -> socket:[2307054]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2725/fd/2 -> socket:[2307056]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2725/fd/20 -> socket:[2290617]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2725/fd/3 -> socket:[2307058]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2739/fd/0 -> socket:[2307052]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2739/fd/1 -> socket:[2307054]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2739/fd/2 -> socket:[2307056]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2739/fd/3 -> socket:[2290618]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2795/fd/0 -> socket:[2321484]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2795/fd/1 -> socket:[2321486]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2795/fd/2 -> socket:[2321488]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/2795/fd/3 -> socket:[2321490]
lrwx------ 1 alex alex 64 Dec 8 14:59 /proc/314/fd/18 -> socket:[2284465]
lrwx------ 1 alex alex 64 Dec 8 14:59 /proc/314/fd/19 -> socket:[2311039]
lrwx------ 1 alex alex 64 Dec 8 14:59 /proc/314/fd/23 -> socket:[2331501]
lrwx------ 1 alex alex 64 Dec 8 14:59 /proc/314/fd/24 -> socket:[2311052]
lrwx------ 1 alex alex 64 Dec 8 14:59 /proc/314/fd/25 -> socket:[2311042]
lrwx------ 1 alex alex 64 Dec 8 14:59 /proc/314/fd/26 -> socket:[2331504]
lrwx------ 1 alex alex 64 Dec 8 14:59 /proc/314/fd/27 -> socket:[2311051]
lrwx------ 1 alex alex 64 Dec 8 14:59 /proc/314/fd/29 -> socket:[2311044]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/314/fd/30 -> socket:[2321909]
lrwx------ 1 alex alex 64 Dec 8 14:59 /proc/314/fd/31 -> socket:[2311046]
lrwx------ 1 alex alex 64 Dec 8 15:14 /proc/314/fd/33 -> socket:[2311048]
lrwx------ 1 alex alex 64 Dec 8 15:17 /proc/314/fd/35 -> socket:[2329692]
lrwx------ 1 alex alex 64 Dec 8 15:17 /proc/314/fd/37 -> socket:[2331506]
lrwx------ 1 alex alex 64 Dec 8 15:20 /proc/314/fd/40 -> socket:[2331508]
lrwx------ 1 alex alex 64 Dec 8 15:20 /proc/314/fd/42 -> socket:[2331510]
lrwx------ 1 alex alex 64 Dec 8 15:17 /proc/314/fd/68 -> socket:[2322083]
lrwx------ 1 alex alex 64 Dec 8 15:22 /proc/4412/fd/20 -> socket:[2335214]
lrwx------ 1 alex alex 64 Dec 8 15:22 /proc/4496/fd/0 -> socket:[2331505]
lrwx------ 1 alex alex 64 Dec 8 15:22 /proc/4496/fd/1 -> socket:[2331507]
lrwx------ 1 alex alex 64 Dec 8 15:22 /proc/4496/fd/2 -> socket:[2331509]
lrwx------ 1 alex alex 64 Dec 8 15:22 /proc/4496/fd/23 -> socket:[2334514]
lrwx------ 1 alex alex 64 Dec 8 15:22 /proc/4496/fd/24 -> socket:[2338989]
lrwx------ 1 alex alex 64 Dec 8 15:22 /proc/4496/fd/26 -> socket:[2338276]
lrwx------ 1 alex alex 64 Dec 8 15:22 /proc/4496/fd/27 -> socket:[2331500]
lrwx------ 1 alex alex 64 Dec 8 15:22 /proc/4496/fd/3 -> socket:[2331511]
lrwx------ 1 alex alex 64 Dec 8 15:22 /proc/4496/fd/31 -> socket:[2338285]`;
const processes: { pid: number, cwd: string, cmd: string }[] = [
{
pid: 230,
cwd: '/mnt/c/WINDOWS/system32',
cmd: 'dockerserve--addressunix:///home/alex/.docker/run/docker-cli-api.sock',
},
{
pid: 2504,
cwd: '/mnt/c/Users/alros/AppData/Local/Programs/Microsoft VS Code Insiders',
cmd: '/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/node/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/out/bootstrap-fork--type=extensionHost--uriTransformerPath=/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/out/vs/server/uriTransformer.js--useHostProxy=',
},
{
pid: 2515,
cwd: '/mnt/c/Users/alros/AppData/Local/Programs/Microsoft VS Code Insiders',
cmd: '/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/node/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/out/bootstrap-fork--type=watcherService'
},
{
pid: 2526,
cwd: '/home/alex/repos/Microsoft/vscode-extension-samples/helloworld-sample',
cmd: '/bin/bash'
}, {
pid: 2719,
cwd: '/mnt/c/Users/alros/AppData/Local/Programs/Microsoft VS Code Insiders',
cmd: '/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/node--max-old-space-size=3072/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/extensions/node_modules/typescript/lib/tsserver.js--serverModepartialSemantic--useInferredProjectPerProjectRoot--disableAutomaticTypingAcquisition--cancellationPipeName/tmp/vscode-typescript1000/7cfa7171c0c00aacf1ee/tscancellation-602cd80b954818b6a2f7.tmp*--logVerbosityverbose--logFile/home/alex/.vscode-server-insiders/data/logs/20201208T145954/exthost2/vscode.typescript-language-features/tsserver-log-nxBt2m/tsserver.log--globalPluginstypescript-vscode-sh-plugin--pluginProbeLocations/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/extensions/typescript-language-features--localeen--noGetErrOnBackgroundUpdate--validateDefaultNpmLocation'
},
{
pid: 2725,
cwd: '/mnt/c/Users/alros/AppData/Local/Programs/Microsoft VS Code Insiders',
cmd: '/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/node--max-old-space-size=3072/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/extensions/node_modules/typescript/lib/tsserver.js--useInferredProjectPerProjectRoot--enableTelemetry--cancellationPipeName/tmp/vscode-typescript1000/7cfa7171c0c00aacf1ee/tscancellation-04a0b92f880c2fd535ae.tmp*--logVerbosityverbose--logFile/home/alex/.vscode-server-insiders/data/logs/20201208T145954/exthost2/vscode.typescript-language-features/tsserver-log-fqyBrs/tsserver.log--globalPluginstypescript-vscode-sh-plugin--pluginProbeLocations/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/extensions/typescript-language-features--localeen--noGetErrOnBackgroundUpdate--validateDefaultNpmLocation'
},
{
pid: 2739,
cwd: '/mnt/c/Users/alros/AppData/Local/Programs/Microsoft VS Code Insiders',
cmd: '/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/node/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/extensions/node_modules/typescript/lib/typingsInstaller.js--globalTypingsCacheLocation/home/alex/.cache/typescript/4.1--enableTelemetry--logFile/home/alex/.vscode-server-insiders/data/logs/20201208T145954/exthost2/vscode.typescript-language-features/tsserver-log-fqyBrs/ti-2725.log--typesMapLocation/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/extensions/node_modules/typescript/lib/typesMap.json--validateDefaultNpmLocation'
},
{
pid: 2795,
cwd: '/home/alex/repos/Microsoft/vscode-extension-samples/helloworld-sample',
cmd: '/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/node/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/extensions/json-language-features/server/dist/node/jsonServerMain--node-ipc--clientProcessId=2504'
},
{
pid: 286,
cwd: '/mnt/c/Users/alros/AppData/Local/Programs/Microsoft VS Code Insiders',
cmd: 'sh-c\"$VSCODE_WSL_EXT_LOCATION/ scripts / wslServer.sh\" bc13785d3dd99b4b0e9da9aed17bb79809a50804 insider .vscode-server-insiders 0 '
},
{
pid: 287,
cwd: '/mnt/c/Users/alros/AppData/Local/Programs/Microsoft VS Code Insiders',
cmd: 'sh/mnt/c/Users/alros/.vscode-insiders/extensions/ms-vscode-remote.remote-wsl-0.52.0/scripts/wslServer.shbc13785d3dd99b4b0e9da9aed17bb79809a50804insider.vscode-server-insiders0'
},
{
pid: 3058,
cwd: '/home/alex/repos/Microsoft/vscode-extension-samples/helloworld-sample',
cmd: 'npm'
},
{
pid: 3070,
cwd: '/home/alex/repos/Microsoft/vscode-extension-samples/helloworld-sample',
cmd: 'sh-ctsc -watch -p ./'
},
{
pid: 3071,
cwd: '/home/alex/repos/Microsoft/vscode-extension-samples/helloworld-sample',
cmd: 'node/home/alex/repos/Microsoft/vscode-extension-samples/helloworld-sample/node_modules/.bin/tsc-watch-p./'
},
{
pid: 312,
cwd: '/mnt/c/Users/alros/AppData/Local/Programs/Microsoft VS Code Insiders',
cmd: 'sh/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/server.sh--port=0--use-host-proxy--enable-remote-auto-shutdown--print-ip-address'
},
{
pid: 314,
cwd: '/mnt/c/Users/alros/AppData/Local/Programs/Microsoft VS Code Insiders',
cmd: '/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/node/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/out/vs/server/main.js--port=0--use-host-proxy--enable-remote-auto-shutdown--print-ip-address'
},
{
pid: 3172,
cwd: '/home/alex',
cmd: '/bin/bash'
},
{
pid: 3610,
cwd: '/home/alex/repos/Microsoft/vscode-extension-samples/helloworld-sample',
cmd: '/bin/bash'
},
{
pid: 4412,
cwd: '/home/alex/repos/Microsoft/vscode-extension-samples/helloworld-sample',
cmd: 'http-server'
},
{
pid: 4496,
cwd: '/mnt/c/Users/alros/AppData/Local/Programs/Microsoft VS Code Insiders',
cmd: '/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/node--inspect-brk=0.0.0.0:6899/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/out/bootstrap-fork--type=extensionHost--uriTransformerPath=/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/out/vs/server/uriTransformer.js--useHostProxy='
},
{
pid: 4507,
cwd: '/mnt/c/Users/alros/AppData/Local/Programs/Microsoft VS Code Insiders',
cmd: '/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/node/home/alex/.vscode-server-insiders/bin/bc13785d3dd99b4b0e9da9aed17bb79809a50804/extensions/ms-vscode.js-debug/src/hash.bundle.js'
}
];
if (platform.isLinux) {
suite('ExtHostTunnelService', () => {
test('getSockets', function () {
const result = getSockets(procSockets);
assert.equal(result.length, 78);
// 4412 is the pid fo the http-server in the test data
assert.notEqual(result.find(value => value.pid === 4412), undefined);
});
test('loadConnectionTable', function () {
const result = loadConnectionTable(tcp);
assert.equal(result.length, 6);
assert.deepEqual(result[0], {
10: '1',
11: '0000000010173312',
12: '100',
13: '0',
14: '0',
15: '10',
16: '0',
inode: '2335214',
local_address: '00000000:0BBA',
rem_address: '00000000:0000',
retrnsmt: '00000000',
sl: '0:',
st: '0A',
timeout: '0',
tr: '00:00000000',
tx_queue: '00000000:00000000',
uid: '1000'
});
});
test('loadListeningPorts', function () {
const result = loadListeningPorts(tcp, tcp6);
// There should be 7 based on the input data. One of them should be 3002.
assert.equal(result.length, 7);
assert.notEqual(result.find(value => value.port === 3002), undefined);
});
test('findPorts', async function () {
const result = await findPorts(tcp, tcp6, procSockets, processes);
assert.equal(result.length, 1);
assert.equal(result[0].host, '0.0.0.0');
assert.equal(result[0].port, 3002);
assert.equal(result[0].detail, 'http-server');
});
});
}