mirror of
https://github.com/coder/code-server.git
synced 2026-06-20 08:57:09 +02:00
chore(vscode): update to 1.54.2
This commit is contained in:
@@ -1147,7 +1147,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
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)];
|
||||
return [new types.InlineHint('Foo', new types.Range(0, 1, 2, 3))];
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -1167,13 +1167,15 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
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)];
|
||||
return [new types.InlineHint('Bar', new types.Range(10, 11, 12, 13))];
|
||||
}
|
||||
}));
|
||||
|
||||
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)];
|
||||
const hint = new types.InlineHint('Foo', new types.Range(0, 1, 2, 3), types.InlineHintKind.Parameter);
|
||||
hint.description = new types.MarkdownString('**Hello**');
|
||||
return [hint];
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -1201,7 +1203,7 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
||||
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)];
|
||||
return [new types.InlineHint('Foo', new types.Range(0, 1, 2, 3))];
|
||||
}
|
||||
}));
|
||||
disposables.push(extHost.registerInlineHintsProvider(nullExtensionDescription, defaultSelector, <vscode.InlineHintsProvider>{
|
||||
|
||||
@@ -18,6 +18,7 @@ import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitData
|
||||
import { IExtHostFileSystemInfo } from 'vs/workbench/api/common/extHostFileSystemInfo';
|
||||
import { FileSystemProviderCapabilities } from 'vs/platform/files/common/files';
|
||||
import { isLinux } from 'vs/base/common/platform';
|
||||
import { WorkspaceTrustState } from 'vs/platform/workspace/common/workspaceTrust';
|
||||
|
||||
suite('ExtHostConfiguration', function () {
|
||||
|
||||
@@ -318,7 +319,7 @@ suite('ExtHostConfiguration', function () {
|
||||
'id': 'foo',
|
||||
'folders': [aWorkspaceFolder(URI.file('foo'), 0)],
|
||||
'name': 'foo'
|
||||
});
|
||||
}, WorkspaceTrustState.Trusted);
|
||||
const testObject = new ExtHostConfigProvider(
|
||||
new class extends mock<MainThreadConfigurationShape>() { },
|
||||
extHostWorkspace,
|
||||
@@ -394,7 +395,7 @@ suite('ExtHostConfiguration', function () {
|
||||
'id': 'foo',
|
||||
'folders': [aWorkspaceFolder(firstRoot, 0), aWorkspaceFolder(secondRoot, 1)],
|
||||
'name': 'foo'
|
||||
});
|
||||
}, WorkspaceTrustState.Trusted);
|
||||
const testObject = new ExtHostConfigProvider(
|
||||
new class extends mock<MainThreadConfigurationShape>() { },
|
||||
extHostWorkspace,
|
||||
@@ -497,7 +498,7 @@ suite('ExtHostConfiguration', function () {
|
||||
'id': 'foo',
|
||||
'folders': [aWorkspaceFolder(firstRoot, 0), aWorkspaceFolder(secondRoot, 1)],
|
||||
'name': 'foo'
|
||||
});
|
||||
}, WorkspaceTrustState.Trusted);
|
||||
const testObject = new ExtHostConfigProvider(
|
||||
new class extends mock<MainThreadConfigurationShape>() { },
|
||||
extHostWorkspace,
|
||||
@@ -675,7 +676,7 @@ suite('ExtHostConfiguration', function () {
|
||||
'id': 'foo',
|
||||
'folders': [workspaceFolder],
|
||||
'name': 'foo'
|
||||
});
|
||||
}, WorkspaceTrustState.Trusted);
|
||||
const testObject = new ExtHostConfigProvider(
|
||||
new class extends mock<MainThreadConfigurationShape>() { },
|
||||
extHostWorkspace,
|
||||
|
||||
@@ -21,6 +21,7 @@ import { nullExtensionDescription } from 'vs/workbench/services/extensions/commo
|
||||
import { isEqual } from 'vs/base/common/resources';
|
||||
import { IExtensionStoragePaths } from 'vs/workbench/api/common/extHostStoragePaths';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
|
||||
suite('NotebookCell#Document', function () {
|
||||
|
||||
@@ -33,9 +34,11 @@ suite('NotebookCell#Document', function () {
|
||||
const notebookUri = URI.parse('test:///notebook.file');
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
setup(async function () {
|
||||
teardown(function () {
|
||||
disposables.clear();
|
||||
});
|
||||
|
||||
setup(async function () {
|
||||
rpcProtocol = new TestRPCProtocol();
|
||||
rpcProtocol.set(MainContext.MainThreadCommands, new class extends mock<MainThreadCommandsShape>() {
|
||||
$registerCommand() { }
|
||||
@@ -82,7 +85,7 @@ suite('NotebookCell#Document', function () {
|
||||
addedEditors: [{
|
||||
documentUri: notebookUri,
|
||||
id: '_notebook_editor_0',
|
||||
selections: [0],
|
||||
selections: [{ start: 0, end: 1 }],
|
||||
visibleRanges: []
|
||||
}]
|
||||
});
|
||||
@@ -305,4 +308,49 @@ suite('NotebookCell#Document', function () {
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 3);
|
||||
assert.strictEqual(second.index, 2);
|
||||
});
|
||||
|
||||
test('ERR MISSING extHostDocument for notebook cell: #116711', async function () {
|
||||
|
||||
const p = Event.toPromise(extHostNotebooks.onDidChangeNotebookCells);
|
||||
|
||||
// DON'T call this, make sure the cell-documents have not been created yet
|
||||
// assert.strictEqual(notebook.notebookDocument.cells.length, 2);
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebook.uri, {
|
||||
versionId: 100,
|
||||
rawEvents: [{
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
changes: [[0, 2, [{
|
||||
handle: 3,
|
||||
uri: CellUri.generate(notebookUri, 3),
|
||||
source: ['### Heading'],
|
||||
eol: '\n',
|
||||
language: 'markdown',
|
||||
cellKind: CellKind.Markdown,
|
||||
outputs: [],
|
||||
}, {
|
||||
handle: 4,
|
||||
uri: CellUri.generate(notebookUri, 4),
|
||||
source: ['console.log("aaa")', 'console.log("bbb")'],
|
||||
eol: '\n',
|
||||
language: 'javascript',
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}]]]
|
||||
}]
|
||||
}, false);
|
||||
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 2);
|
||||
|
||||
const event = await p;
|
||||
|
||||
assert.strictEqual(event.document === notebook.notebookDocument, true);
|
||||
assert.strictEqual(event.changes.length, 1);
|
||||
assert.strictEqual(event.changes[0].deletedCount, 2);
|
||||
assert.strictEqual(event.changes[0].deletedItems[0].document.isClosed, true);
|
||||
assert.strictEqual(event.changes[0].deletedItems[1].document.isClosed, true);
|
||||
assert.strictEqual(event.changes[0].items.length, 2);
|
||||
assert.strictEqual(event.changes[0].items[0].document.isClosed, false);
|
||||
assert.strictEqual(event.changes[0].items[1].document.isClosed, false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -75,7 +75,7 @@ suite('NotebookConcatDocument', function () {
|
||||
{
|
||||
documentUri: notebookUri,
|
||||
id: '_notebook_editor_0',
|
||||
selections: [0],
|
||||
selections: [{ start: 0, end: 1 }],
|
||||
visibleRanges: []
|
||||
}
|
||||
]
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { TestRPCProtocol } from 'vs/workbench/test/browser/api/testRPCProtocol';
|
||||
import { ExtHostDocuments } from 'vs/workbench/api/common/extHostDocuments';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { ExtHostNotebookController } from 'vs/workbench/api/common/extHostNotebook';
|
||||
import { ExtHostNotebookDocument } from 'vs/workbench/api/common/extHostNotebookDocument';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { CellKind, CellUri } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||
import { nullExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import * as vscode from 'vscode';
|
||||
import { mock } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
import { MainContext, MainThreadCommandsShape, MainThreadNotebookShape } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IExtensionStoragePaths } from 'vs/workbench/api/common/extHostStoragePaths';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
suite('NotebookKernel', function () {
|
||||
|
||||
let rpcProtocol: TestRPCProtocol;
|
||||
let notebook: ExtHostNotebookDocument;
|
||||
let extHostDocumentsAndEditors: ExtHostDocumentsAndEditors;
|
||||
let extHostDocuments: ExtHostDocuments;
|
||||
let extHostNotebooks: ExtHostNotebookController;
|
||||
const notebookUri = URI.parse('test:///notebook.file');
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
setup(async function () {
|
||||
disposables.clear();
|
||||
|
||||
rpcProtocol = new TestRPCProtocol();
|
||||
rpcProtocol.set(MainContext.MainThreadCommands, new class extends mock<MainThreadCommandsShape>() {
|
||||
$registerCommand() { }
|
||||
});
|
||||
rpcProtocol.set(MainContext.MainThreadNotebook, new class extends mock<MainThreadNotebookShape>() {
|
||||
async $registerNotebookProvider() { }
|
||||
async $unregisterNotebookProvider() { }
|
||||
async $registerNotebookKernelProvider() { }
|
||||
async $unregisterNotebookKernelProvider() { }
|
||||
});
|
||||
extHostDocumentsAndEditors = new ExtHostDocumentsAndEditors(rpcProtocol, new NullLogService());
|
||||
extHostDocuments = new ExtHostDocuments(rpcProtocol, extHostDocumentsAndEditors);
|
||||
const extHostStoragePaths = new class extends mock<IExtensionStoragePaths>() {
|
||||
workspaceValue() {
|
||||
return URI.from({ scheme: 'test', path: generateUuid() });
|
||||
}
|
||||
};
|
||||
extHostNotebooks = new ExtHostNotebookController(rpcProtocol, new ExtHostCommands(rpcProtocol, new NullLogService()), extHostDocumentsAndEditors, { isExtensionDevelopmentDebug: false, webviewCspSource: '', webviewResourceRoot: '' }, new NullLogService(), extHostStoragePaths);
|
||||
let reg = extHostNotebooks.registerNotebookContentProvider(nullExtensionDescription, 'test', new class extends mock<vscode.NotebookContentProvider>() {
|
||||
// async openNotebook() { }
|
||||
});
|
||||
|
||||
const kernels = [new class extends mock<vscode.NotebookKernel>() {
|
||||
id = 'first';
|
||||
}, new class extends mock<vscode.NotebookKernel>() {
|
||||
id = 'second';
|
||||
}];
|
||||
|
||||
let kernelReg = extHostNotebooks.registerNotebookKernelProvider(nullExtensionDescription, { viewType: 'test' }, new class extends mock<vscode.NotebookKernelProvider>() {
|
||||
async provideKernels() { return kernels; }
|
||||
});
|
||||
|
||||
// init
|
||||
extHostNotebooks.$acceptDocumentAndEditorsDelta({
|
||||
addedDocuments: [{
|
||||
uri: notebookUri,
|
||||
viewType: 'test',
|
||||
cells: [{
|
||||
handle: 0,
|
||||
uri: CellUri.generate(notebookUri, 0),
|
||||
source: ['console.log'],
|
||||
eol: '\n',
|
||||
language: 'javascript',
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}],
|
||||
contentOptions: { transientOutputs: false, transientMetadata: {} },
|
||||
versionId: 0
|
||||
}],
|
||||
addedEditors: [
|
||||
{
|
||||
documentUri: notebookUri,
|
||||
id: '_notebook_editor_0',
|
||||
selections: [{ start: 0, end: 1 }],
|
||||
visibleRanges: []
|
||||
}
|
||||
]
|
||||
});
|
||||
extHostNotebooks.$acceptDocumentAndEditorsDelta({ newActiveEditor: '_notebook_editor_0' });
|
||||
|
||||
notebook = extHostNotebooks.notebookDocuments[0]!;
|
||||
|
||||
disposables.add(reg);
|
||||
disposables.add(kernelReg);
|
||||
disposables.add(notebook);
|
||||
disposables.add(extHostDocuments);
|
||||
});
|
||||
|
||||
test('provide kernels', async function () {
|
||||
const dto = await extHostNotebooks.$provideNotebookKernels(0, notebook.uri, CancellationToken.None);
|
||||
assert.deepStrictEqual(dto.map(kernel => kernel.id), ['first', 'second']);
|
||||
});
|
||||
});
|
||||
@@ -17,7 +17,6 @@ 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;
|
||||
}
|
||||
@@ -62,7 +61,7 @@ suite('ExtHost Testing', () => {
|
||||
|
||||
teardown(() => {
|
||||
single.dispose();
|
||||
assert.strictEqual(owned.idToInternal.size, 0, 'expected owned ids to be empty after dispose');
|
||||
assert.strictEqual(!owned.idToInternal?.size, true, 'expected owned ids to be empty after dispose');
|
||||
});
|
||||
|
||||
suite('OwnedTestCollection', () => {
|
||||
@@ -70,11 +69,11 @@ suite('ExtHost Testing', () => {
|
||||
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'), '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') }],
|
||||
[TestDiffOpType.Add, { providerId: 'pid', parent: null, item: convert.TestItem.from(stubTest('root')) }],
|
||||
[TestDiffOpType.Add, { providerId: 'pid', parent: 'id-root', item: convert.TestItem.from(stubTest('a')) }],
|
||||
[TestDiffOpType.Add, { providerId: 'pid', parent: 'id-a', item: convert.TestItem.from(stubTest('aa')) }],
|
||||
[TestDiffOpType.Add, { providerId: 'pid', parent: 'id-a', item: convert.TestItem.from(stubTest('ab')) }],
|
||||
[TestDiffOpType.Add, { providerId: 'pid', parent: 'id-root', item: convert.TestItem.from(stubTest('b')) }],
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -92,7 +91,7 @@ suite('ExtHost Testing', () => {
|
||||
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' }, 'root') }],
|
||||
[TestDiffOpType.Update, { parent: 'id-root', providerId: 'pid', item: convert.TestItem.from({ ...stubTest('a'), description: 'Hello world' }) }],
|
||||
]);
|
||||
|
||||
single.onItemChange(tests, 'pid');
|
||||
@@ -107,9 +106,9 @@ suite('ExtHost Testing', () => {
|
||||
single.onItemChange(tests, 'pid');
|
||||
|
||||
assert.deepStrictEqual(single.collectDiff(), [
|
||||
[TestDiffOpType.Remove, '1'],
|
||||
[TestDiffOpType.Remove, 'id-a'],
|
||||
]);
|
||||
assert.deepStrictEqual([...owned.idToInternal.keys()].sort(), ['0', '4']);
|
||||
assert.deepStrictEqual([...owned.idToInternal].map(n => n.item.extId).sort(), ['id-b', 'id-root']);
|
||||
assert.strictEqual(single.itemToInternal.size, 2);
|
||||
});
|
||||
|
||||
@@ -122,9 +121,12 @@ suite('ExtHost Testing', () => {
|
||||
single.onItemChange(tests, 'pid');
|
||||
|
||||
assert.deepStrictEqual(single.collectDiff(), [
|
||||
[TestDiffOpType.Add, { id: '5', providerId: 'pid', parent: '1', item: convert.TestItem.from(child, 'root\0a') }],
|
||||
[TestDiffOpType.Add, { providerId: 'pid', parent: 'id-a', item: convert.TestItem.from(child) }],
|
||||
]);
|
||||
assert.deepStrictEqual([...owned.idToInternal.keys()].sort(), ['0', '1', '2', '3', '4', '5']);
|
||||
assert.deepStrictEqual(
|
||||
[...owned.idToInternal].map(n => n.item.extId).sort(),
|
||||
['id-a', 'id-aa', 'id-ab', 'id-ac', 'id-b', 'id-root'],
|
||||
);
|
||||
assert.strictEqual(single.itemToInternal.size, 6);
|
||||
});
|
||||
});
|
||||
@@ -137,7 +139,7 @@ suite('ExtHost Testing', () => {
|
||||
const tests = testStubs.nested();
|
||||
single.addRoot(tests, 'pid');
|
||||
m.apply(single.collectDiff());
|
||||
assertTreesEqual(m.rootTestItems[0], owned.getTestById('0')!.actual);
|
||||
assertTreesEqual(m.rootTestItems[0], owned.getTestById('id-root')![1].actual);
|
||||
assert.strictEqual(m.length, single.itemToInternal.size);
|
||||
});
|
||||
|
||||
@@ -149,7 +151,7 @@ suite('ExtHost Testing', () => {
|
||||
single.onItemChange(tests, 'pid');
|
||||
m.apply(single.collectDiff());
|
||||
|
||||
assertTreesEqual(m.rootTestItems[0], owned.getTestById('0')!.actual);
|
||||
assertTreesEqual(m.rootTestItems[0], owned.getTestById('id-root')![1].actual);
|
||||
assert.strictEqual(m.length, single.itemToInternal.size);
|
||||
});
|
||||
|
||||
@@ -161,7 +163,7 @@ suite('ExtHost Testing', () => {
|
||||
single.onItemChange(tests, 'pid');
|
||||
m.apply(single.collectDiff());
|
||||
|
||||
assertTreesEqual(m.rootTestItems[0], owned.getTestById('0')!.actual);
|
||||
assertTreesEqual(m.rootTestItems[0], owned.getTestById('id-root')![1].actual);
|
||||
assert.strictEqual(m.length, single.itemToInternal.size);
|
||||
});
|
||||
|
||||
@@ -173,7 +175,7 @@ suite('ExtHost Testing', () => {
|
||||
single.onItemChange(tests, 'pid');
|
||||
m.apply(single.collectDiff());
|
||||
|
||||
assertTreesEqual(m.rootTestItems[0], owned.getTestById('0')!.actual);
|
||||
assertTreesEqual(m.rootTestItems[0], owned.getTestById('id-root')![1].actual);
|
||||
});
|
||||
|
||||
suite('MirroredChangeCollector', () => {
|
||||
@@ -224,7 +226,7 @@ suite('ExtHost Testing', () => {
|
||||
});
|
||||
|
||||
test('is a no-op if a node is added and removed', () => {
|
||||
const nested = testStubs.nested();
|
||||
const nested = testStubs.nested('id2-');
|
||||
tests.children.push(nested);
|
||||
single.onItemChange(tests, 'pid');
|
||||
tests.children.pop();
|
||||
@@ -326,7 +328,6 @@ suite('ExtHost Testing', () => {
|
||||
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', () => {
|
||||
|
||||
@@ -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.strictEqual(3, editor.viewColumn);
|
||||
assert.strictEqual(3, editor.value.viewColumn);
|
||||
|
||||
editor.dispose();
|
||||
|
||||
assert.throws(() => editor._acceptViewColumn(2));
|
||||
assert.strictEqual(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,15 +48,15 @@ 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 => { });
|
||||
await editor.value.edit(edit => { });
|
||||
assert.strictEqual(applyCount, 0);
|
||||
|
||||
await editor.edit(edit => { edit.setEndOfLine(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)); });
|
||||
await editor.value.edit(edit => { edit.delete(new Range(0, 0, 1, 1)); });
|
||||
assert.strictEqual(applyCount, 2);
|
||||
});
|
||||
});
|
||||
@@ -89,7 +90,6 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
};
|
||||
opts = new ExtHostTextEditorOptions(mockProxy, '1', {
|
||||
tabSize: 4,
|
||||
indentSize: 4,
|
||||
insertSpaces: false,
|
||||
cursorStyle: TextEditorCursorStyle.Line,
|
||||
lineNumbers: RenderLineNumbersType.On
|
||||
@@ -103,20 +103,18 @@ 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.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
|
||||
@@ -125,10 +123,9 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
|
||||
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
|
||||
@@ -137,10 +134,9 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
|
||||
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
|
||||
@@ -149,10 +145,9 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
|
||||
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
|
||||
@@ -161,10 +156,9 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
|
||||
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
|
||||
@@ -173,10 +167,9 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
|
||||
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
|
||||
@@ -185,10 +178,9 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
|
||||
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
|
||||
@@ -197,10 +189,9 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
|
||||
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
|
||||
@@ -209,130 +200,9 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
|
||||
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.deepStrictEqual(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.deepStrictEqual(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.deepStrictEqual(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.deepStrictEqual(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.deepStrictEqual(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.deepStrictEqual(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.deepStrictEqual(calls, []);
|
||||
});
|
||||
|
||||
test('ignores invalid indentSize 1', () => {
|
||||
opts.indentSize = null!;
|
||||
assertState(opts, {
|
||||
tabSize: 4,
|
||||
indentSize: 4,
|
||||
insertSpaces: false,
|
||||
cursorStyle: TextEditorCursorStyle.Line,
|
||||
lineNumbers: RenderLineNumbersType.On
|
||||
});
|
||||
assert.deepStrictEqual(calls, []);
|
||||
});
|
||||
|
||||
test('ignores invalid indentSize 2', () => {
|
||||
opts.indentSize = -5;
|
||||
assertState(opts, {
|
||||
tabSize: 4,
|
||||
indentSize: 4,
|
||||
insertSpaces: false,
|
||||
cursorStyle: TextEditorCursorStyle.Line,
|
||||
lineNumbers: RenderLineNumbersType.On
|
||||
});
|
||||
assert.deepStrictEqual(calls, []);
|
||||
});
|
||||
|
||||
test('ignores invalid indentSize 3', () => {
|
||||
opts.indentSize = 'hello';
|
||||
assertState(opts, {
|
||||
tabSize: 4,
|
||||
indentSize: 4,
|
||||
insertSpaces: false,
|
||||
cursorStyle: TextEditorCursorStyle.Line,
|
||||
lineNumbers: RenderLineNumbersType.On
|
||||
});
|
||||
assert.deepStrictEqual(calls, []);
|
||||
});
|
||||
|
||||
test('ignores invalid indentSize 4', () => {
|
||||
opts.indentSize = '-17';
|
||||
assertState(opts, {
|
||||
tabSize: 4,
|
||||
indentSize: 4,
|
||||
insertSpaces: false,
|
||||
cursorStyle: TextEditorCursorStyle.Line,
|
||||
lineNumbers: RenderLineNumbersType.On
|
||||
@@ -341,10 +211,9 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
|
||||
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
|
||||
@@ -353,10 +222,9 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
|
||||
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
|
||||
@@ -365,10 +233,9 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
|
||||
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
|
||||
@@ -377,10 +244,9 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
|
||||
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
|
||||
@@ -389,10 +255,9 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
|
||||
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
|
||||
@@ -401,10 +266,9 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
|
||||
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
|
||||
@@ -413,10 +277,9 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
|
||||
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
|
||||
@@ -425,10 +288,9 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
|
||||
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
|
||||
@@ -437,10 +299,9 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
|
||||
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
|
||||
@@ -457,7 +318,6 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
assertState(opts, {
|
||||
tabSize: 4,
|
||||
indentSize: 4,
|
||||
insertSpaces: false,
|
||||
cursorStyle: TextEditorCursorStyle.Line,
|
||||
lineNumbers: RenderLineNumbersType.On
|
||||
@@ -472,7 +332,6 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
assertState(opts, {
|
||||
tabSize: 4,
|
||||
indentSize: 4,
|
||||
insertSpaces: true,
|
||||
cursorStyle: TextEditorCursorStyle.Line,
|
||||
lineNumbers: RenderLineNumbersType.On
|
||||
@@ -487,7 +346,6 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
assertState(opts, {
|
||||
tabSize: 3,
|
||||
indentSize: 4,
|
||||
insertSpaces: false,
|
||||
cursorStyle: TextEditorCursorStyle.Line,
|
||||
lineNumbers: RenderLineNumbersType.On
|
||||
@@ -502,7 +360,6 @@ suite('ExtHostTextEditorOptions', () => {
|
||||
});
|
||||
assertState(opts, {
|
||||
tabSize: 4,
|
||||
indentSize: 4,
|
||||
insertSpaces: false,
|
||||
cursorStyle: TextEditorCursorStyle.Block,
|
||||
lineNumbers: RenderLineNumbersType.Relative
|
||||
|
||||
@@ -26,7 +26,7 @@ suite('ExtHostTreeView', function () {
|
||||
|
||||
onRefresh = new Emitter<{ [treeItemHandle: string]: ITreeItem }>();
|
||||
|
||||
$registerTreeViewDataProvider(treeViewId: string): void {
|
||||
async $registerTreeViewDataProvider(treeViewId: string): Promise<void> {
|
||||
}
|
||||
|
||||
$refresh(viewId: string, itemsToRefresh: { [treeItemHandle: string]: ITreeItem }): Promise<void> {
|
||||
@@ -196,6 +196,7 @@ suite('ExtHostTreeView', function () {
|
||||
'aa': {},
|
||||
'ba': {}
|
||||
};
|
||||
let caughtExpectedError = false;
|
||||
target.onRefresh.event(() => {
|
||||
testObject.$getChildren('testNodeWithIdTreeProvider')
|
||||
.then(elements => {
|
||||
@@ -204,7 +205,8 @@ suite('ExtHostTreeView', function () {
|
||||
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);
|
||||
@@ -602,7 +604,7 @@ suite('ExtHostTreeView', function () {
|
||||
const treeView = testObject.createTreeView('treeDataProvider', { treeDataProvider: aCompleteNodeTreeDataProvider() }, { enableProposedApi: true } as IExtensionDescription);
|
||||
return loadCompleteTree('treeDataProvider')
|
||||
.then(() => {
|
||||
runWithEventMerging((resolve) => {
|
||||
return runWithEventMerging((resolve) => {
|
||||
tree = {
|
||||
'a': {
|
||||
'aa': {},
|
||||
@@ -631,9 +633,9 @@ suite('ExtHostTreeView', function () {
|
||||
.then(() => {
|
||||
assert.ok(revealTarget.calledOnce);
|
||||
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]);
|
||||
assert.deepStrictEqual({ handle: '0/0:b/0:bc', label: { label: 'bc' }, collapsibleState: TreeItemCollapsibleState.None, parentHandle: '0/0:b' }, removeUnsetKeys(revealTarget.args[0][1].item));
|
||||
assert.deepStrictEqual([{ handle: '0/0:b', label: { label: 'b' }, collapsibleState: TreeItemCollapsibleState.Collapsed }], (<Array<any>>revealTarget.args[0][1].parentChain).map(arg => removeUnsetKeys(arg)));
|
||||
assert.deepStrictEqual({ select: true, focus: false, expand: false }, revealTarget.args[0][2]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ import { URI } from 'vs/base/common/uri';
|
||||
import * as types from 'vs/workbench/api/common/extHostTypes';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { assertType } from 'vs/base/common/types';
|
||||
import { notebookDocumentMetadataDefaults } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
|
||||
function assertToJSON(a: any, expected: any) {
|
||||
const raw = JSON.stringify(a);
|
||||
@@ -648,4 +649,59 @@ suite('ExtHostTypes', function () {
|
||||
assert.deepStrictEqual(md.value, '\n```html\n<img src=0 onerror="alert(1)">\n```\n');
|
||||
});
|
||||
|
||||
test('NotebookMetadata - defaults', function () {
|
||||
const obj = new types.NotebookDocumentMetadata();
|
||||
assert.strictEqual(obj.cellEditable, notebookDocumentMetadataDefaults.cellEditable);
|
||||
assert.strictEqual(obj.cellHasExecutionOrder, notebookDocumentMetadataDefaults.cellHasExecutionOrder);
|
||||
assert.strictEqual(obj.cellRunnable, notebookDocumentMetadataDefaults.cellRunnable);
|
||||
assert.deepStrictEqual(obj.custom, notebookDocumentMetadataDefaults.custom);
|
||||
assert.deepStrictEqual(obj.displayOrder, notebookDocumentMetadataDefaults.displayOrder);
|
||||
assert.strictEqual(obj.editable, notebookDocumentMetadataDefaults.editable);
|
||||
assert.strictEqual(obj.runState, notebookDocumentMetadataDefaults.runState);
|
||||
assert.strictEqual(obj.runnable, notebookDocumentMetadataDefaults.runnable);
|
||||
assert.strictEqual(obj.trusted, notebookDocumentMetadataDefaults.trusted);
|
||||
});
|
||||
|
||||
test('NotebookMetadata - with', function () {
|
||||
const obj = new types.NotebookDocumentMetadata();
|
||||
const newObj = obj.with({ trusted: false });
|
||||
assert.ok(obj !== newObj);
|
||||
const sameObj = newObj.with({ trusted: false });
|
||||
assert.ok(newObj === sameObj);
|
||||
assert.strictEqual(obj.trusted, true);
|
||||
assert.strictEqual(newObj.trusted, false);
|
||||
});
|
||||
|
||||
test('NotebookCellMetadata - with', function () {
|
||||
const obj = new types.NotebookCellMetadata(true, false, true);
|
||||
|
||||
const newObj = obj.with({ statusMessage: 'hello' });
|
||||
assert.ok(obj !== newObj);
|
||||
assert.strictEqual(obj.statusMessage, undefined);
|
||||
assert.strictEqual(obj.editable, true);
|
||||
assert.strictEqual(obj.custom, undefined);
|
||||
|
||||
assert.strictEqual(newObj.statusMessage, 'hello');
|
||||
assert.strictEqual(newObj.editable, true);
|
||||
assert.strictEqual(newObj.custom, undefined);
|
||||
|
||||
});
|
||||
|
||||
test('Unable to reset executionOrder of cells #116956', function () {
|
||||
|
||||
let obj = new types.NotebookCellMetadata();
|
||||
assert.strictEqual(obj.executionOrder, undefined);
|
||||
|
||||
obj = obj.with({ executionOrder: 23 });
|
||||
assert.strictEqual(obj.executionOrder, 23);
|
||||
|
||||
obj = obj.with({ executionOrder: undefined });
|
||||
assert.strictEqual(obj.executionOrder, 23);
|
||||
|
||||
obj = obj.with({});
|
||||
assert.strictEqual(obj.executionOrder, 23);
|
||||
|
||||
obj = obj.with({ executionOrder: null });
|
||||
assert.strictEqual(obj.executionOrder, undefined);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,6 +23,7 @@ import { IPatternInfo } from 'vs/workbench/services/search/common/search';
|
||||
import { isLinux, isWindows } from 'vs/base/common/platform';
|
||||
import { IExtHostFileSystemInfo } from 'vs/workbench/api/common/extHostFileSystemInfo';
|
||||
import { FileSystemProviderCapabilities } from 'vs/platform/files/common/files';
|
||||
import { WorkspaceTrustState } from 'vs/platform/workspace/common/workspaceTrust';
|
||||
|
||||
function createExtHostWorkspace(mainContext: IMainContext, data: IWorkspaceData, logService: ILogService): ExtHostWorkspace {
|
||||
const result = new ExtHostWorkspace(
|
||||
@@ -31,7 +32,7 @@ function createExtHostWorkspace(mainContext: IMainContext, data: IWorkspaceData,
|
||||
new class extends mock<IExtHostFileSystemInfo>() { getCapabilities() { return isLinux ? FileSystemProviderCapabilities.PathCaseSensitive : undefined; } },
|
||||
logService,
|
||||
);
|
||||
result.$initializeWorkspace(data);
|
||||
result.$initializeWorkspace(data, WorkspaceTrustState.Trusted);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ suite('BoundModelReferenceCollection', () => {
|
||||
dispose() {
|
||||
disposed.push(0);
|
||||
}
|
||||
});
|
||||
}, 6);
|
||||
|
||||
col.add(
|
||||
URI.parse('test://boofar'),
|
||||
@@ -55,7 +55,7 @@ suite('BoundModelReferenceCollection', () => {
|
||||
dispose() {
|
||||
disposed.push(1);
|
||||
}
|
||||
});
|
||||
}, 6);
|
||||
|
||||
col.add(
|
||||
URI.parse('test://xxxxxxx'),
|
||||
@@ -64,7 +64,7 @@ suite('BoundModelReferenceCollection', () => {
|
||||
dispose() {
|
||||
disposed.push(2);
|
||||
}
|
||||
});
|
||||
}, 70);
|
||||
|
||||
assert.deepStrictEqual(disposed, [0, 1]);
|
||||
});
|
||||
|
||||
@@ -48,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!,
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -20,218 +20,217 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { TestContextService, TestStorageService } from 'vs/workbench/test/common/workbenchTestServices';
|
||||
|
||||
function inst(): IInstantiationService {
|
||||
let inst = new TestInstantiationService();
|
||||
inst.stub(IStorageService, new TestStorageService());
|
||||
inst.stub(ILifecycleService, new TestLifecycleService());
|
||||
inst.stub(IWorkspaceContextService, new TestContextService());
|
||||
inst.stub(ITelemetryService, NullTelemetryService);
|
||||
|
||||
const config = new TestConfigurationService();
|
||||
config.setUserConfiguration('workbench', { editor: { openPositioning: 'right', focusRecentEditorAfterClose: true } });
|
||||
inst.stub(IConfigurationService, config);
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
function createGroup(serialized?: ISerializedEditorGroup): EditorGroup {
|
||||
return inst().createInstance(EditorGroup, serialized);
|
||||
}
|
||||
|
||||
function closeAllEditors(group: EditorGroup): void {
|
||||
for (const editor of group.getEditors(EditorsOrder.SEQUENTIAL)) {
|
||||
group.closeEditor(editor, false);
|
||||
}
|
||||
}
|
||||
|
||||
function closeEditors(group: EditorGroup, except: EditorInput, direction?: CloseDirection): void {
|
||||
const index = group.indexOf(except);
|
||||
if (index === -1) {
|
||||
return; // not found
|
||||
}
|
||||
|
||||
// Close to the left
|
||||
if (direction === CloseDirection.LEFT) {
|
||||
for (let i = index - 1; i >= 0; i--) {
|
||||
group.closeEditor(group.getEditorByIndex(i)!);
|
||||
}
|
||||
}
|
||||
|
||||
// Close to the right
|
||||
else if (direction === CloseDirection.RIGHT) {
|
||||
for (let i = group.getEditors(EditorsOrder.SEQUENTIAL).length - 1; i > index; i--) {
|
||||
group.closeEditor(group.getEditorByIndex(i)!);
|
||||
}
|
||||
}
|
||||
|
||||
// Both directions
|
||||
else {
|
||||
group.getEditors(EditorsOrder.MOST_RECENTLY_ACTIVE).filter(editor => !editor.matches(except)).forEach(editor => group.closeEditor(editor));
|
||||
}
|
||||
}
|
||||
|
||||
interface GroupEvents {
|
||||
opened: EditorInput[];
|
||||
activated: EditorInput[];
|
||||
closed: EditorCloseEvent[];
|
||||
pinned: EditorInput[];
|
||||
unpinned: EditorInput[];
|
||||
sticky: EditorInput[];
|
||||
unsticky: EditorInput[];
|
||||
moved: EditorInput[];
|
||||
disposed: EditorInput[];
|
||||
}
|
||||
|
||||
function groupListener(group: EditorGroup): GroupEvents {
|
||||
const groupEvents: GroupEvents = {
|
||||
opened: [],
|
||||
closed: [],
|
||||
activated: [],
|
||||
pinned: [],
|
||||
unpinned: [],
|
||||
sticky: [],
|
||||
unsticky: [],
|
||||
moved: [],
|
||||
disposed: []
|
||||
};
|
||||
|
||||
group.onDidOpenEditor(e => groupEvents.opened.push(e));
|
||||
group.onDidCloseEditor(e => groupEvents.closed.push(e));
|
||||
group.onDidActivateEditor(e => groupEvents.activated.push(e));
|
||||
group.onDidChangeEditorPinned(e => group.isPinned(e) ? groupEvents.pinned.push(e) : groupEvents.unpinned.push(e));
|
||||
group.onDidChangeEditorSticky(e => group.isSticky(e) ? groupEvents.sticky.push(e) : groupEvents.unsticky.push(e));
|
||||
group.onDidMoveEditor(e => groupEvents.moved.push(e));
|
||||
group.onDidDisposeEditor(e => groupEvents.disposed.push(e));
|
||||
|
||||
return groupEvents;
|
||||
}
|
||||
|
||||
let index = 0;
|
||||
class TestEditorInput extends EditorInput {
|
||||
|
||||
readonly resource = undefined;
|
||||
|
||||
constructor(public id: string) {
|
||||
super();
|
||||
}
|
||||
getTypeId() { return 'testEditorInputForGroups'; }
|
||||
resolve(): Promise<IEditorModel> { return Promise.resolve(null!); }
|
||||
|
||||
matches(other: TestEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof TestEditorInput;
|
||||
}
|
||||
|
||||
setDirty(): void {
|
||||
this._onDidChangeDirty.fire();
|
||||
}
|
||||
|
||||
setLabel(): void {
|
||||
this._onDidChangeLabel.fire();
|
||||
}
|
||||
}
|
||||
|
||||
class NonSerializableTestEditorInput extends EditorInput {
|
||||
|
||||
readonly resource = undefined;
|
||||
|
||||
constructor(public id: string) {
|
||||
super();
|
||||
}
|
||||
getTypeId() { return 'testEditorInputForGroups-nonSerializable'; }
|
||||
resolve(): Promise<IEditorModel> { return Promise.resolve(null!); }
|
||||
|
||||
matches(other: NonSerializableTestEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof NonSerializableTestEditorInput;
|
||||
}
|
||||
}
|
||||
|
||||
class TestFileEditorInput extends EditorInput implements IFileEditorInput {
|
||||
|
||||
readonly preferredResource = this.resource;
|
||||
|
||||
constructor(public id: string, public resource: URI) {
|
||||
super();
|
||||
}
|
||||
getTypeId() { return 'testFileEditorInputForGroups'; }
|
||||
resolve(): Promise<IEditorModel> { return Promise.resolve(null!); }
|
||||
setPreferredName(name: string): void { }
|
||||
setPreferredDescription(description: string): void { }
|
||||
setPreferredResource(resource: URI): void { }
|
||||
setEncoding(encoding: string) { }
|
||||
getEncoding() { return undefined; }
|
||||
setPreferredEncoding(encoding: string) { }
|
||||
setForceOpenAsBinary(): void { }
|
||||
setMode(mode: string) { }
|
||||
setPreferredMode(mode: string) { }
|
||||
isResolved(): boolean { return false; }
|
||||
|
||||
matches(other: TestFileEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof TestFileEditorInput;
|
||||
}
|
||||
}
|
||||
|
||||
function input(id = String(index++), nonSerializable?: boolean, resource?: URI): EditorInput {
|
||||
if (resource) {
|
||||
return new TestFileEditorInput(id, resource);
|
||||
}
|
||||
|
||||
return nonSerializable ? new NonSerializableTestEditorInput(id) : new TestEditorInput(id);
|
||||
}
|
||||
|
||||
interface ISerializedTestInput {
|
||||
id: string;
|
||||
}
|
||||
|
||||
class TestEditorInputFactory implements IEditorInputFactory {
|
||||
|
||||
static disableSerialize = false;
|
||||
static disableDeserialize = false;
|
||||
|
||||
canSerialize(editorInput: EditorInput): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
serialize(editorInput: EditorInput): string | undefined {
|
||||
if (TestEditorInputFactory.disableSerialize) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let testEditorInput = <TestEditorInput>editorInput;
|
||||
let testInput: ISerializedTestInput = {
|
||||
id: testEditorInput.id
|
||||
};
|
||||
|
||||
return JSON.stringify(testInput);
|
||||
}
|
||||
|
||||
deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): EditorInput | undefined {
|
||||
if (TestEditorInputFactory.disableDeserialize) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let testInput: ISerializedTestInput = JSON.parse(serializedEditorInput);
|
||||
|
||||
return new TestEditorInput(testInput.id);
|
||||
}
|
||||
}
|
||||
|
||||
suite('Workbench editor groups', () => {
|
||||
|
||||
let disposables: IDisposable[] = [];
|
||||
function inst(): IInstantiationService {
|
||||
let inst = new TestInstantiationService();
|
||||
inst.stub(IStorageService, new TestStorageService());
|
||||
inst.stub(ILifecycleService, new TestLifecycleService());
|
||||
inst.stub(IWorkspaceContextService, new TestContextService());
|
||||
inst.stub(ITelemetryService, NullTelemetryService);
|
||||
|
||||
const config = new TestConfigurationService();
|
||||
config.setUserConfiguration('workbench', { editor: { openPositioning: 'right', focusRecentEditorAfterClose: true } });
|
||||
inst.stub(IConfigurationService, config);
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
function createGroup(serialized?: ISerializedEditorGroup): EditorGroup {
|
||||
return inst().createInstance(EditorGroup, serialized);
|
||||
}
|
||||
|
||||
function closeAllEditors(group: EditorGroup): void {
|
||||
for (const editor of group.getEditors(EditorsOrder.SEQUENTIAL)) {
|
||||
group.closeEditor(editor, false);
|
||||
}
|
||||
}
|
||||
|
||||
function closeEditors(group: EditorGroup, except: EditorInput, direction?: CloseDirection): void {
|
||||
const index = group.indexOf(except);
|
||||
if (index === -1) {
|
||||
return; // not found
|
||||
}
|
||||
|
||||
// Close to the left
|
||||
if (direction === CloseDirection.LEFT) {
|
||||
for (let i = index - 1; i >= 0; i--) {
|
||||
group.closeEditor(group.getEditorByIndex(i)!);
|
||||
}
|
||||
}
|
||||
|
||||
// Close to the right
|
||||
else if (direction === CloseDirection.RIGHT) {
|
||||
for (let i = group.getEditors(EditorsOrder.SEQUENTIAL).length - 1; i > index; i--) {
|
||||
group.closeEditor(group.getEditorByIndex(i)!);
|
||||
}
|
||||
}
|
||||
|
||||
// Both directions
|
||||
else {
|
||||
group.getEditors(EditorsOrder.MOST_RECENTLY_ACTIVE).filter(editor => !editor.matches(except)).forEach(editor => group.closeEditor(editor));
|
||||
}
|
||||
}
|
||||
|
||||
interface GroupEvents {
|
||||
opened: EditorInput[];
|
||||
activated: EditorInput[];
|
||||
closed: EditorCloseEvent[];
|
||||
pinned: EditorInput[];
|
||||
unpinned: EditorInput[];
|
||||
sticky: EditorInput[];
|
||||
unsticky: EditorInput[];
|
||||
moved: EditorInput[];
|
||||
disposed: EditorInput[];
|
||||
}
|
||||
|
||||
function groupListener(group: EditorGroup): GroupEvents {
|
||||
const groupEvents: GroupEvents = {
|
||||
opened: [],
|
||||
closed: [],
|
||||
activated: [],
|
||||
pinned: [],
|
||||
unpinned: [],
|
||||
sticky: [],
|
||||
unsticky: [],
|
||||
moved: [],
|
||||
disposed: []
|
||||
};
|
||||
|
||||
group.onDidOpenEditor(e => groupEvents.opened.push(e));
|
||||
group.onDidCloseEditor(e => groupEvents.closed.push(e));
|
||||
group.onDidActivateEditor(e => groupEvents.activated.push(e));
|
||||
group.onDidChangeEditorPinned(e => group.isPinned(e) ? groupEvents.pinned.push(e) : groupEvents.unpinned.push(e));
|
||||
group.onDidChangeEditorSticky(e => group.isSticky(e) ? groupEvents.sticky.push(e) : groupEvents.unsticky.push(e));
|
||||
group.onDidMoveEditor(e => groupEvents.moved.push(e));
|
||||
group.onDidDisposeEditor(e => groupEvents.disposed.push(e));
|
||||
|
||||
return groupEvents;
|
||||
}
|
||||
|
||||
let index = 0;
|
||||
class TestEditorInput extends EditorInput {
|
||||
|
||||
readonly resource = undefined;
|
||||
|
||||
constructor(public id: string) {
|
||||
super();
|
||||
}
|
||||
getTypeId() { return 'testEditorInputForGroups'; }
|
||||
async resolve(): Promise<IEditorModel> { return null!; }
|
||||
|
||||
matches(other: TestEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof TestEditorInput;
|
||||
}
|
||||
|
||||
setDirty(): void {
|
||||
this._onDidChangeDirty.fire();
|
||||
}
|
||||
|
||||
setLabel(): void {
|
||||
this._onDidChangeLabel.fire();
|
||||
}
|
||||
}
|
||||
|
||||
class NonSerializableTestEditorInput extends EditorInput {
|
||||
|
||||
readonly resource = undefined;
|
||||
|
||||
constructor(public id: string) {
|
||||
super();
|
||||
}
|
||||
getTypeId() { return 'testEditorInputForGroups-nonSerializable'; }
|
||||
async resolve(): Promise<IEditorModel | null> { return null; }
|
||||
|
||||
matches(other: NonSerializableTestEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof NonSerializableTestEditorInput;
|
||||
}
|
||||
}
|
||||
|
||||
class TestFileEditorInput extends EditorInput implements IFileEditorInput {
|
||||
|
||||
readonly preferredResource = this.resource;
|
||||
|
||||
constructor(public id: string, public resource: URI) {
|
||||
super();
|
||||
}
|
||||
getTypeId() { return 'testFileEditorInputForGroups'; }
|
||||
async resolve(): Promise<IEditorModel | null> { return null; }
|
||||
setPreferredName(name: string): void { }
|
||||
setPreferredDescription(description: string): void { }
|
||||
setPreferredResource(resource: URI): void { }
|
||||
setEncoding(encoding: string) { }
|
||||
getEncoding() { return undefined; }
|
||||
setPreferredEncoding(encoding: string) { }
|
||||
setForceOpenAsBinary(): void { }
|
||||
setMode(mode: string) { }
|
||||
setPreferredMode(mode: string) { }
|
||||
isResolved(): boolean { return false; }
|
||||
|
||||
matches(other: TestFileEditorInput): boolean {
|
||||
return other && this.id === other.id && other instanceof TestFileEditorInput;
|
||||
}
|
||||
}
|
||||
|
||||
function input(id = String(index++), nonSerializable?: boolean, resource?: URI): EditorInput {
|
||||
if (resource) {
|
||||
return new TestFileEditorInput(id, resource);
|
||||
}
|
||||
|
||||
return nonSerializable ? new NonSerializableTestEditorInput(id) : new TestEditorInput(id);
|
||||
}
|
||||
|
||||
interface ISerializedTestInput {
|
||||
id: string;
|
||||
}
|
||||
|
||||
class TestEditorInputFactory implements IEditorInputFactory {
|
||||
|
||||
static disableSerialize = false;
|
||||
static disableDeserialize = false;
|
||||
|
||||
canSerialize(editorInput: EditorInput): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
serialize(editorInput: EditorInput): string | undefined {
|
||||
if (TestEditorInputFactory.disableSerialize) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let testEditorInput = <TestEditorInput>editorInput;
|
||||
let testInput: ISerializedTestInput = {
|
||||
id: testEditorInput.id
|
||||
};
|
||||
|
||||
return JSON.stringify(testInput);
|
||||
}
|
||||
|
||||
deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): EditorInput | undefined {
|
||||
if (TestEditorInputFactory.disableDeserialize) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let testInput: ISerializedTestInput = JSON.parse(serializedEditorInput);
|
||||
|
||||
return new TestEditorInput(testInput.id);
|
||||
}
|
||||
}
|
||||
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
setup(() => {
|
||||
TestEditorInputFactory.disableSerialize = false;
|
||||
TestEditorInputFactory.disableDeserialize = false;
|
||||
|
||||
disposables.push(Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).registerEditorInputFactory('testEditorInputForGroups', TestEditorInputFactory));
|
||||
disposables.add(Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).registerEditorInputFactory('testEditorInputForGroups', TestEditorInputFactory));
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
dispose(disposables);
|
||||
disposables = [];
|
||||
disposables.clear();
|
||||
|
||||
index = 1;
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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.strictEqual(model.isDisposed(), false);
|
||||
assert.strictEqual(m.isResolved(), true);
|
||||
m.dispose();
|
||||
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(model.isDisposed(), true);
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 () {
|
||||
@@ -251,9 +260,6 @@ suite('Workbench EditorPane', () => {
|
||||
assert.ok(!memento.loadEditorState(testGroup4, URI.file('/C')));
|
||||
assert.ok(memento.loadEditorState(testGroup0, URI.file('/D')));
|
||||
assert.ok(!memento.loadEditorState(testGroup0, URI.file('/E')));
|
||||
|
||||
// Use fallbackToOtherGroupState
|
||||
assert.ok(memento.loadEditorState(testGroup4, URI.file('/C'), true));
|
||||
});
|
||||
|
||||
test('EditorMemento - move', function () {
|
||||
@@ -299,7 +305,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;
|
||||
@@ -337,7 +343,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;
|
||||
|
||||
@@ -4,21 +4,23 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
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', () => {
|
||||
|
||||
class TestViewlet extends Viewlet {
|
||||
|
||||
constructor() {
|
||||
super('id', null!, null!, null!, null!, null!, null!, null!, null!, null!, null!);
|
||||
super('id', null!, null!, null!, null!, null!, null!, null!, null!, null!);
|
||||
}
|
||||
|
||||
layout(dimension: any): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
createViewPaneContainer() { return null!; }
|
||||
}
|
||||
|
||||
test('ViewletDescriptor API', function () {
|
||||
@@ -40,15 +42,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.strictEqual(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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,15 +3,14 @@
|
||||
* Licensed under the MIT License. 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 { IEditorOpeningEvent, EditorServiceImpl, IEditorGroupView, IEditorGroupsAccessor, IEditorGroupTitleDimensions } from 'vs/workbench/browser/parts/editor/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, IEditorGroupTitleHeight } from 'vs/workbench/browser/parts/editor/editor';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
|
||||
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -52,7 +51,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IDecorationsService, IResourceDecorationChangeEvent, IDecoration, IDecorationData, IDecorationsProvider } from 'vs/workbench/services/decorations/browser/decorations';
|
||||
import { IDisposable, toDisposable, Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IEditorGroupsService, IEditorGroup, GroupsOrder, GroupsArrangement, GroupDirection, IAddGroupOptions, IMergeGroupOptions, IMoveEditorOptions, ICopyEditorOptions, IEditorReplacement, IGroupChangeEvent, IFindGroupScope, EditorGroupLayout, ICloseEditorOptions, GroupOrientation, ICloseAllEditorsOptions, ICloseEditorsFilter } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IEditorService, IOpenEditorOverrideHandler, ISaveEditorsOptions, IRevertAllEditorsOptions, IResourceEditorInputType, SIDE_GROUP_TYPE, ACTIVE_GROUP_TYPE, IOpenEditorOverrideEntry, ICustomEditorViewTypesHandler } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEditorService, IOpenEditorOverrideHandler, ISaveEditorsOptions, IRevertAllEditorsOptions, IResourceEditorInputType, SIDE_GROUP_TYPE, ACTIVE_GROUP_TYPE, IOpenEditorOverrideEntry } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { IEditorRegistry, EditorDescriptor, Extensions } from 'vs/workbench/browser/editor';
|
||||
import { EditorGroup } from 'vs/workbench/common/editor/editorGroup';
|
||||
@@ -70,7 +69,7 @@ import { Part } from 'vs/workbench/browser/part';
|
||||
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
|
||||
import { IPanel } from 'vs/workbench/common/panel';
|
||||
import { IBadge } from 'vs/workbench/services/activity/common/activity';
|
||||
import { VSBuffer, VSBufferReadable } from 'vs/base/common/buffer';
|
||||
import { bufferToStream, VSBuffer, VSBufferReadable } from 'vs/base/common/buffer';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
@@ -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';
|
||||
@@ -118,11 +117,45 @@ import { InMemoryBackupFileService } from 'vs/workbench/services/backup/common/b
|
||||
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';
|
||||
import { IWorkspaceTrustService } from 'vs/platform/workspace/common/workspaceTrust';
|
||||
import { TestWorkspaceTrustService } from 'vs/workbench/services/workspaces/test/common/testWorkspaceTrustService';
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -191,6 +224,8 @@ export function workbenchInstantiationService(
|
||||
instantiationService.stub(IViewletService, new TestViewletService());
|
||||
instantiationService.stub(IListService, new TestListService());
|
||||
instantiationService.stub(IQuickInputService, disposables.add(new QuickInputService(configService, instantiationService, keybindingService, contextKeyService, themeService, accessibilityService, layoutService)));
|
||||
instantiationService.stub(IWorkspacesService, new TestWorkspacesService());
|
||||
instantiationService.stub(IWorkspaceTrustService, new TestWorkspaceTrustService());
|
||||
|
||||
return instantiationService;
|
||||
}
|
||||
@@ -379,7 +414,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 []; }
|
||||
@@ -428,16 +463,14 @@ export class TestLayoutService implements IWorkbenchLayoutService {
|
||||
|
||||
container: HTMLElement = window.document.body;
|
||||
|
||||
onZenModeChange: Event<boolean> = Event.None;
|
||||
onCenteredLayoutChange: Event<boolean> = Event.None;
|
||||
onFullscreenChange: Event<boolean> = Event.None;
|
||||
onMaximizeChange: Event<boolean> = Event.None;
|
||||
onPanelPositionChange: Event<string> = Event.None;
|
||||
onPartVisibilityChange: Event<void> = Event.None;
|
||||
onLayout = Event.None;
|
||||
|
||||
private readonly _onMenubarVisibilityChange = new Emitter<Dimension>();
|
||||
get onMenubarVisibilityChange(): Event<Dimension> { return this._onMenubarVisibilityChange.event; }
|
||||
onDidChangeZenMode: Event<boolean> = Event.None;
|
||||
onDidChangeCenteredLayout: Event<boolean> = Event.None;
|
||||
onDidChangeFullscreen: Event<boolean> = Event.None;
|
||||
onDidChangeWindowMaximized: Event<boolean> = Event.None;
|
||||
onDidChangePanelPosition: Event<string> = Event.None;
|
||||
onDidChangePartVisibility: Event<void> = Event.None;
|
||||
onDidLayout = Event.None;
|
||||
onDidChangeNotificationsVisibility = Event.None;
|
||||
|
||||
layout(): void { }
|
||||
isRestored(): boolean { return true; }
|
||||
@@ -540,6 +573,7 @@ export class TestViewsService implements IViewsService {
|
||||
onDidChangeViewVisibility = this.onDidChangeViewVisibilityEmitter.event;
|
||||
isViewVisible(id: string): boolean { return true; }
|
||||
getActiveViewWithId<T extends IView>(id: string): T | null { return null; }
|
||||
getViewWithId<T extends IView>(id: string): T | null { return null; }
|
||||
openView<T extends IView>(id: string, focus?: boolean | undefined): Promise<T | null> { return Promise.resolve(null); }
|
||||
closeView(id: string): void { }
|
||||
getViewProgressIndicator(id: string) { return null!; }
|
||||
@@ -552,14 +586,14 @@ export class TestEditorGroupsService implements IEditorGroupsService {
|
||||
|
||||
constructor(public groups: TestEditorGroupView[] = []) { }
|
||||
|
||||
onDidActiveGroupChange: Event<IEditorGroup> = Event.None;
|
||||
onDidChangeActiveGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidActivateGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidAddGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidRemoveGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidMoveGroup: Event<IEditorGroup> = Event.None;
|
||||
onDidGroupIndexChange: Event<IEditorGroup> = Event.None;
|
||||
onDidChangeGroupIndex: Event<IEditorGroup> = Event.None;
|
||||
onDidLayout: Event<IDimension> = Event.None;
|
||||
onDidEditorPartOptionsChange = Event.None;
|
||||
onDidChangeEditorPartOptions = Event.None;
|
||||
|
||||
orientation = GroupOrientation.HORIZONTAL;
|
||||
whenRestored: Promise<void> = Promise.resolve(undefined);
|
||||
@@ -615,7 +649,7 @@ export class TestEditorGroupView implements IEditorGroupView {
|
||||
minimumHeight!: number;
|
||||
maximumHeight!: number;
|
||||
|
||||
titleDimensions!: IEditorGroupTitleDimensions;
|
||||
titleHeight!: IEditorGroupTitleHeight;
|
||||
|
||||
isEmpty = true;
|
||||
isMinimized = false;
|
||||
@@ -664,7 +698,7 @@ export class TestEditorGroupAccessor implements IEditorGroupsAccessor {
|
||||
|
||||
partOptions: IEditorPartOptions = {};
|
||||
|
||||
onDidEditorPartOptionsChange = Event.None;
|
||||
onDidChangeEditorPartOptions = Event.None;
|
||||
onDidVisibilityChange = Event.None;
|
||||
|
||||
getGroup(identifier: number): IEditorGroupView | undefined { throw new Error('Method not implemented.'); }
|
||||
@@ -712,9 +746,6 @@ export class TestEditorService implements EditorServiceImpl {
|
||||
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 {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
openEditor(editor: IEditorInput, options?: IEditorOptions | ITextEditorOptions, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Promise<IEditorPane | undefined>;
|
||||
openEditor(editor: IResourceEditorInput | IUntitledTextResourceEditorInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Promise<ITextEditorPane | undefined>;
|
||||
openEditor(editor: IResourceDiffEditorInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Promise<ITextDiffEditorPane | undefined>;
|
||||
@@ -772,7 +803,7 @@ export class TestFileService implements IFileService {
|
||||
isFile: true,
|
||||
isDirectory: false,
|
||||
isSymbolicLink: false,
|
||||
name: resources.basename(resource)
|
||||
name: basename(resource)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -794,7 +825,7 @@ export class TestFileService implements IFileService {
|
||||
encoding: 'utf8',
|
||||
mtime: Date.now(),
|
||||
ctime: Date.now(),
|
||||
name: resources.basename(resource),
|
||||
name: basename(resource),
|
||||
size: 1
|
||||
});
|
||||
}
|
||||
@@ -804,26 +835,13 @@ export class TestFileService implements IFileService {
|
||||
|
||||
return Promise.resolve({
|
||||
resource,
|
||||
value: {
|
||||
on: (event: string, callback: Function): void => {
|
||||
if (event === 'data') {
|
||||
callback(this.content);
|
||||
}
|
||||
if (event === 'end') {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
removeListener: () => { },
|
||||
resume: () => { },
|
||||
pause: () => { },
|
||||
destroy: () => { }
|
||||
},
|
||||
value: bufferToStream(VSBuffer.fromString(this.content)),
|
||||
etag: 'index.txt',
|
||||
encoding: 'utf8',
|
||||
mtime: Date.now(),
|
||||
ctime: Date.now(),
|
||||
size: 1,
|
||||
name: resources.basename(resource)
|
||||
name: basename(resource)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -845,7 +863,7 @@ export class TestFileService implements IFileService {
|
||||
isFile: true,
|
||||
isDirectory: false,
|
||||
isSymbolicLink: false,
|
||||
name: resources.basename(resource)
|
||||
name: basename(resource)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -988,9 +1006,15 @@ export class TestLifecycleService implements ILifecycleService {
|
||||
|
||||
async when(): Promise<void> { }
|
||||
|
||||
shutdownJoiners: Promise<void>[] = [];
|
||||
|
||||
fireShutdown(reason = ShutdownReason.QUIT): void {
|
||||
this.shutdownJoiners = [];
|
||||
|
||||
this._onWillShutdown.fire({
|
||||
join: () => { },
|
||||
join: p => {
|
||||
this.shutdownJoiners.push(p);
|
||||
},
|
||||
reason
|
||||
});
|
||||
}
|
||||
@@ -1216,6 +1240,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;
|
||||
@@ -1337,3 +1411,19 @@ export class TestTextFileEditorModelManager extends TextFileEditorModelManager {
|
||||
return super.remove(resource);
|
||||
}
|
||||
}
|
||||
|
||||
export class TestWorkspacesService implements IWorkspacesService {
|
||||
_serviceBrand: undefined;
|
||||
|
||||
onDidChangeRecentlyOpened = 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.'); }
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as assert from 'assert';
|
||||
import { NotificationsModel, NotificationViewItem, INotificationChangeEvent, NotificationChangeType, NotificationViewItemContentChangeKind, IStatusMessageChangeEvent, StatusMessageChangeType } from 'vs/workbench/common/notifications';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { INotification, Severity, NotificationsFilter } from 'vs/platform/notification/common/notification';
|
||||
import { createErrorWithActions } from 'vs/base/common/errorsWithActions';
|
||||
import { createErrorWithActions } from 'vs/base/common/errors';
|
||||
|
||||
suite('Notifications', () => {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
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';
|
||||
@@ -104,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,7 +115,7 @@ export class TestContextService implements IWorkspaceContextService {
|
||||
}
|
||||
|
||||
isCurrentWorkspace(workspaceIdOrFolder: IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI): boolean {
|
||||
return URI.isUri(workspaceIdOrFolder) && resources.isEqual(this.workspace.folders[0].uri, workspaceIdOrFolder);
|
||||
return URI.isUri(workspaceIdOrFolder) && isEqual(this.workspace.folders[0].uri, workspaceIdOrFolder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,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;
|
||||
|
||||
|
||||
@@ -713,10 +713,10 @@ suite('ExtHostSearch', () => {
|
||||
match: null // Don't care about this right now
|
||||
}
|
||||
} : {
|
||||
uri: r.uri.toString(),
|
||||
text: r.text,
|
||||
lineNumber: r.lineNumber
|
||||
});
|
||||
uri: r.uri.toString(),
|
||||
text: r.text,
|
||||
lineNumber: r.lineNumber
|
||||
});
|
||||
|
||||
return assert.deepEqual(
|
||||
makeComparable(actualTextSearchResults),
|
||||
@@ -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',
|
||||
|
||||
@@ -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'];
|
||||
|
||||
@@ -202,7 +202,8 @@ class TestTelemetryService implements ITelemetryService {
|
||||
return Promise.resolve({
|
||||
instanceId: 'someValue.instanceId',
|
||||
sessionId: 'someValue.sessionId',
|
||||
machineId: 'someValue.machineId'
|
||||
machineId: 'someValue.machineId',
|
||||
firstSessionDate: 'someValue.firstSessionDate'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { workbenchInstantiationService as browserWorkbenchInstantiationService, ITestInstantiationService, TestLifecycleService, TestFilesConfigurationService, TestFileService, TestFileDialogService, TestPathService, TestEncodingOracle, TestProductService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
|
||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-sandbox/services';
|
||||
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
|
||||
import { NativeTextFileService, } from 'vs/workbench/services/textfile/electron-browser/nativeTextFileService';
|
||||
import { INativeHostService } from 'vs/platform/native/electron-sandbox/native';
|
||||
@@ -55,6 +55,7 @@ export const TestWorkbenchConfiguration: INativeWorkbenchConfiguration = {
|
||||
perfMarks: [],
|
||||
colorScheme: { dark: true, highContrast: false },
|
||||
os: { release: release() },
|
||||
enableExperimentalMainProcessWorkspaceStorage: false,
|
||||
...parseArgs(process.argv, OPTIONS)
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user