mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-14 12:08:36 -05:00
Merge from vscode 7eaf220cafb9d9e901370ffce02229171cbf3ea6
This commit is contained in:
committed by
Anthony Dresser
parent
39d9eed585
commit
a63578e6f7
@@ -81,7 +81,8 @@ suite('NotebookCell#Document', function () {
|
||||
addedEditors: [{
|
||||
documentUri: notebookUri,
|
||||
id: '_notebook_editor_0',
|
||||
selections: [0]
|
||||
selections: [0],
|
||||
visibleRanges: []
|
||||
}]
|
||||
});
|
||||
extHostNotebooks.$acceptDocumentAndEditorsDelta({ newActiveEditor: '_notebook_editor_0' });
|
||||
@@ -96,26 +97,26 @@ suite('NotebookCell#Document', function () {
|
||||
|
||||
test('cell document is vscode.TextDocument', async function () {
|
||||
|
||||
assert.strictEqual(notebook.cells.length, 2);
|
||||
assert.strictEqual(notebook.notebookDocument.cells.length, 2);
|
||||
|
||||
const [c1, c2] = notebook.cells;
|
||||
const [c1, c2] = notebook.notebookDocument.cells;
|
||||
const d1 = extHostDocuments.getDocument(c1.uri);
|
||||
|
||||
assert.ok(d1);
|
||||
assert.equal(d1.languageId, c1.language);
|
||||
assert.equal(d1.version, 1);
|
||||
assert.ok(d1.notebook === notebook);
|
||||
assert.ok(d1.notebook === notebook.notebookDocument);
|
||||
|
||||
const d2 = extHostDocuments.getDocument(c2.uri);
|
||||
assert.ok(d2);
|
||||
assert.equal(d2.languageId, c2.language);
|
||||
assert.equal(d2.version, 1);
|
||||
assert.ok(d2.notebook === notebook);
|
||||
assert.ok(d2.notebook === notebook.notebookDocument);
|
||||
});
|
||||
|
||||
test('cell document goes when notebook closes', async function () {
|
||||
const cellUris: string[] = [];
|
||||
for (let cell of notebook.cells) {
|
||||
for (let cell of notebook.notebookDocument.cells) {
|
||||
assert.ok(extHostDocuments.getDocument(cell.uri));
|
||||
cellUris.push(cell.uri.toString());
|
||||
}
|
||||
@@ -160,7 +161,7 @@ suite('NotebookCell#Document', function () {
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
versionId: notebook.versionId + 1,
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
changes: [[0, 0, [{
|
||||
handle: 2,
|
||||
uri: CellUri.generate(notebookUri, 2),
|
||||
@@ -178,7 +179,7 @@ suite('NotebookCell#Document', function () {
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}]]]
|
||||
});
|
||||
}, false);
|
||||
|
||||
await p;
|
||||
|
||||
@@ -188,7 +189,7 @@ suite('NotebookCell#Document', function () {
|
||||
|
||||
const docs: vscode.TextDocument[] = [];
|
||||
const addData: IModelAddedData[] = [];
|
||||
for (let cell of notebook.cells) {
|
||||
for (let cell of notebook.notebookDocument.cells) {
|
||||
const doc = extHostDocuments.getDocument(cell.uri);
|
||||
assert.ok(doc);
|
||||
assert.equal(extHostDocuments.getDocument(cell.uri).isClosed, false);
|
||||
@@ -210,14 +211,14 @@ suite('NotebookCell#Document', function () {
|
||||
extHostDocumentsAndEditors.$acceptDocumentsAndEditorsDelta({ removedDocuments: docs.map(d => d.uri) });
|
||||
|
||||
// notebook is still open -> cell documents stay open
|
||||
for (let cell of notebook.cells) {
|
||||
for (let cell of notebook.notebookDocument.cells) {
|
||||
assert.ok(extHostDocuments.getDocument(cell.uri));
|
||||
assert.equal(extHostDocuments.getDocument(cell.uri).isClosed, false);
|
||||
}
|
||||
|
||||
// close notebook -> docs are closed
|
||||
extHostNotebooks.$acceptDocumentAndEditorsDelta({ removedDocuments: [notebook.uri] });
|
||||
for (let cell of notebook.cells) {
|
||||
for (let cell of notebook.notebookDocument.cells) {
|
||||
assert.throws(() => extHostDocuments.getDocument(cell.uri));
|
||||
}
|
||||
for (let doc of docs) {
|
||||
@@ -227,16 +228,16 @@ suite('NotebookCell#Document', function () {
|
||||
|
||||
test('cell document goes when cell is removed', async function () {
|
||||
|
||||
assert.equal(notebook.cells.length, 2);
|
||||
const [cell1, cell2] = notebook.cells;
|
||||
assert.equal(notebook.notebookDocument.cells.length, 2);
|
||||
const [cell1, cell2] = notebook.notebookDocument.cells;
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebook.uri, {
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
versionId: 2,
|
||||
changes: [[0, 1, []]]
|
||||
});
|
||||
}, false);
|
||||
|
||||
assert.equal(notebook.cells.length, 1);
|
||||
assert.equal(notebook.notebookDocument.cells.length, 1);
|
||||
assert.equal(cell1.document.isClosed, true); // ref still alive!
|
||||
assert.equal(cell2.document.isClosed, false);
|
||||
|
||||
@@ -244,8 +245,8 @@ suite('NotebookCell#Document', function () {
|
||||
});
|
||||
|
||||
test('cell document knows notebook', function () {
|
||||
for (let cells of notebook.cells) {
|
||||
assert.equal(cells.document.notebook === notebook, true);
|
||||
for (let cells of notebook.notebookDocument.cells) {
|
||||
assert.equal(cells.document.notebook === notebook.notebookDocument, true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -74,7 +74,8 @@ suite('NotebookConcatDocument', function () {
|
||||
{
|
||||
documentUri: notebookUri,
|
||||
id: '_notebook_editor_0',
|
||||
selections: [0]
|
||||
selections: [0],
|
||||
visibleRanges: []
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -88,7 +89,7 @@ suite('NotebookConcatDocument', function () {
|
||||
});
|
||||
|
||||
test('empty', function () {
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
assert.equal(doc.getText(), '');
|
||||
assert.equal(doc.version, 0);
|
||||
|
||||
@@ -125,7 +126,7 @@ suite('NotebookConcatDocument', function () {
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
versionId: notebook.versionId + 1,
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
changes: [[0, 0, [{
|
||||
handle: 1,
|
||||
uri: cellUri1,
|
||||
@@ -143,12 +144,12 @@ suite('NotebookConcatDocument', function () {
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}]]]
|
||||
});
|
||||
}, false);
|
||||
|
||||
|
||||
assert.equal(notebook.cells.length, 1 + 2); // markdown and code
|
||||
assert.equal(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
|
||||
assert.equal(doc.contains(cellUri1), true);
|
||||
assert.equal(doc.contains(cellUri2), true);
|
||||
@@ -159,7 +160,7 @@ suite('NotebookConcatDocument', function () {
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
versionId: notebook.versionId + 1,
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
changes: [[0, 0, [{
|
||||
handle: 1,
|
||||
uri: CellUri.generate(notebook.uri, 1),
|
||||
@@ -177,30 +178,30 @@ suite('NotebookConcatDocument', function () {
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}]]]
|
||||
});
|
||||
}, false);
|
||||
|
||||
|
||||
assert.equal(notebook.cells.length, 1 + 2); // markdown and code
|
||||
assert.equal(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
|
||||
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.cells[0].uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.cells[1].uri, new Position(1, 0)));
|
||||
assertLocation(doc, new Position(4, 3), new Location(notebook.cells[1].uri, new Position(1, 3)));
|
||||
assertLocation(doc, new Position(5, 11), new Location(notebook.cells[1].uri, new Position(2, 11)));
|
||||
assertLocation(doc, new Position(5, 12), new Location(notebook.cells[1].uri, new Position(2, 11)), false); // don't check identity because position will be clamped
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.notebookDocument.cells[1].uri, new Position(1, 0)));
|
||||
assertLocation(doc, new Position(4, 3), new Location(notebook.notebookDocument.cells[1].uri, new Position(1, 3)));
|
||||
assertLocation(doc, new Position(5, 11), new Location(notebook.notebookDocument.cells[1].uri, new Position(2, 11)));
|
||||
assertLocation(doc, new Position(5, 12), new Location(notebook.notebookDocument.cells[1].uri, new Position(2, 11)), false); // don't check identity because position will be clamped
|
||||
});
|
||||
|
||||
|
||||
test('location, position mapping, cell changes', function () {
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
|
||||
// UPDATE 1
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
versionId: notebook.versionId + 1,
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
changes: [[0, 0, [{
|
||||
handle: 1,
|
||||
uri: CellUri.generate(notebook.uri, 1),
|
||||
@@ -210,20 +211,20 @@ suite('NotebookConcatDocument', function () {
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}]]]
|
||||
});
|
||||
assert.equal(notebook.cells.length, 1 + 1);
|
||||
}, false);
|
||||
assert.equal(notebook.notebookDocument.cells.length, 1 + 1);
|
||||
assert.equal(doc.version, 1);
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!');
|
||||
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.cells[0].uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(2, 2), new Location(notebook.cells[0].uri, new Position(2, 2)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.cells[0].uri, new Position(2, 12)), false); // clamped
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(2, 2), new Location(notebook.notebookDocument.cells[0].uri, new Position(2, 2)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(2, 12)), false); // clamped
|
||||
|
||||
|
||||
// UPDATE 2
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
versionId: notebook.versionId + 1,
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
changes: [[1, 0, [{
|
||||
handle: 2,
|
||||
uri: CellUri.generate(notebook.uri, 2),
|
||||
@@ -233,39 +234,39 @@ suite('NotebookConcatDocument', function () {
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}]]]
|
||||
});
|
||||
}, false);
|
||||
|
||||
assert.equal(notebook.cells.length, 1 + 2);
|
||||
assert.equal(notebook.notebookDocument.cells.length, 1 + 2);
|
||||
assert.equal(doc.version, 2);
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.cells[0].uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.cells[1].uri, new Position(1, 0)));
|
||||
assertLocation(doc, new Position(4, 3), new Location(notebook.cells[1].uri, new Position(1, 3)));
|
||||
assertLocation(doc, new Position(5, 11), new Location(notebook.cells[1].uri, new Position(2, 11)));
|
||||
assertLocation(doc, new Position(5, 12), new Location(notebook.cells[1].uri, new Position(2, 11)), false); // don't check identity because position will be clamped
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.notebookDocument.cells[1].uri, new Position(1, 0)));
|
||||
assertLocation(doc, new Position(4, 3), new Location(notebook.notebookDocument.cells[1].uri, new Position(1, 3)));
|
||||
assertLocation(doc, new Position(5, 11), new Location(notebook.notebookDocument.cells[1].uri, new Position(2, 11)));
|
||||
assertLocation(doc, new Position(5, 12), new Location(notebook.notebookDocument.cells[1].uri, new Position(2, 11)), false); // don't check identity because position will be clamped
|
||||
|
||||
// UPDATE 3 (remove cell #2 again)
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
versionId: notebook.versionId + 1,
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
changes: [[1, 1, []]]
|
||||
});
|
||||
assert.equal(notebook.cells.length, 1 + 1);
|
||||
}, false);
|
||||
assert.equal(notebook.notebookDocument.cells.length, 1 + 1);
|
||||
assert.equal(doc.version, 3);
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!');
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.cells[0].uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(2, 2), new Location(notebook.cells[0].uri, new Position(2, 2)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.cells[0].uri, new Position(2, 12)), false); // clamped
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(2, 2), new Location(notebook.notebookDocument.cells[0].uri, new Position(2, 2)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(2, 12)), false); // clamped
|
||||
});
|
||||
|
||||
test('location, position mapping, cell-document changes', function () {
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
|
||||
// UPDATE 1
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
versionId: notebook.versionId + 1,
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
changes: [[0, 0, [{
|
||||
handle: 1,
|
||||
uri: CellUri.generate(notebook.uri, 1),
|
||||
@@ -283,22 +284,22 @@ suite('NotebookConcatDocument', function () {
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}]]]
|
||||
});
|
||||
assert.equal(notebook.cells.length, 1 + 2);
|
||||
}, false);
|
||||
assert.equal(notebook.notebookDocument.cells.length, 1 + 2);
|
||||
assert.equal(doc.version, 1);
|
||||
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.cells[0].uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(2, 2), new Location(notebook.cells[0].uri, new Position(2, 2)));
|
||||
assertLocation(doc, new Position(2, 12), new Location(notebook.cells[0].uri, new Position(2, 12)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.cells[1].uri, new Position(1, 0)));
|
||||
assertLocation(doc, new Position(4, 3), new Location(notebook.cells[1].uri, new Position(1, 3)));
|
||||
assertLocation(doc, new Position(0, 0), new Location(notebook.notebookDocument.cells[0].uri, new Position(0, 0)));
|
||||
assertLocation(doc, new Position(2, 2), new Location(notebook.notebookDocument.cells[0].uri, new Position(2, 2)));
|
||||
assertLocation(doc, new Position(2, 12), new Location(notebook.notebookDocument.cells[0].uri, new Position(2, 12)));
|
||||
assertLocation(doc, new Position(4, 0), new Location(notebook.notebookDocument.cells[1].uri, new Position(1, 0)));
|
||||
assertLocation(doc, new Position(4, 3), new Location(notebook.notebookDocument.cells[1].uri, new Position(1, 3)));
|
||||
|
||||
// offset math
|
||||
let cell1End = doc.offsetAt(new Position(2, 12));
|
||||
assert.equal(doc.positionAt(cell1End).isEqual(new Position(2, 12)), true);
|
||||
|
||||
extHostDocuments.$acceptModelChanged(notebook.cells[0].uri, {
|
||||
extHostDocuments.$acceptModelChanged(notebook.notebookDocument.cells[0].uri, {
|
||||
versionId: 0,
|
||||
eol: '\n',
|
||||
changes: [{
|
||||
@@ -309,7 +310,7 @@ suite('NotebookConcatDocument', function () {
|
||||
}]
|
||||
}, false);
|
||||
assertLines(doc, 'Hello', 'World', 'Hi World!', 'Hallo', 'Welt', 'Hallo Welt!');
|
||||
assertLocation(doc, new Position(2, 12), new Location(notebook.cells[0].uri, new Position(2, 9)), false);
|
||||
assertLocation(doc, new Position(2, 12), new Location(notebook.notebookDocument.cells[0].uri, new Position(2, 9)), false);
|
||||
|
||||
assert.equal(doc.positionAt(cell1End).isEqual(new Position(3, 2)), true);
|
||||
|
||||
@@ -319,7 +320,7 @@ suite('NotebookConcatDocument', function () {
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
versionId: notebook.versionId + 1,
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
changes: [[0, 0, [{
|
||||
handle: 1,
|
||||
uri: CellUri.generate(notebook.uri, 1),
|
||||
@@ -337,11 +338,11 @@ suite('NotebookConcatDocument', function () {
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}]]]
|
||||
});
|
||||
}, false);
|
||||
|
||||
const mixedDoc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook, undefined);
|
||||
const fooLangDoc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook, 'fooLang');
|
||||
const barLangDoc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook, 'barLang');
|
||||
const mixedDoc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
const fooLangDoc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, 'fooLang');
|
||||
const barLangDoc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, 'barLang');
|
||||
|
||||
assertLines(mixedDoc, 'fooLang-document', 'barLang-document');
|
||||
assertLines(fooLangDoc, 'fooLang-document');
|
||||
@@ -349,7 +350,7 @@ suite('NotebookConcatDocument', function () {
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
versionId: notebook.versionId + 1,
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
changes: [[2, 0, [{
|
||||
handle: 3,
|
||||
uri: CellUri.generate(notebook.uri, 3),
|
||||
@@ -359,7 +360,7 @@ suite('NotebookConcatDocument', function () {
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}]]]
|
||||
});
|
||||
}, false);
|
||||
|
||||
assertLines(mixedDoc, 'fooLang-document', 'barLang-document', 'barLang-document2');
|
||||
assertLines(fooLangDoc, 'fooLang-document');
|
||||
@@ -383,7 +384,7 @@ suite('NotebookConcatDocument', function () {
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
versionId: notebook.versionId + 1,
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
changes: [[0, 0, [{
|
||||
handle: 1,
|
||||
uri: CellUri.generate(notebook.uri, 1),
|
||||
@@ -401,11 +402,11 @@ suite('NotebookConcatDocument', function () {
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}]]]
|
||||
});
|
||||
}, false);
|
||||
|
||||
assert.equal(notebook.cells.length, 1 + 2); // markdown and code
|
||||
assert.equal(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
|
||||
|
||||
assertOffsetAtPosition(doc, 0, { line: 0, character: 0 });
|
||||
@@ -436,7 +437,7 @@ suite('NotebookConcatDocument', function () {
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
versionId: notebook.versionId + 1,
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
changes: [[0, 0, [{
|
||||
handle: 1,
|
||||
uri: CellUri.generate(notebook.uri, 1),
|
||||
@@ -454,26 +455,26 @@ suite('NotebookConcatDocument', function () {
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}]]]
|
||||
});
|
||||
}, false);
|
||||
|
||||
assert.equal(notebook.cells.length, 1 + 2); // markdown and code
|
||||
assert.equal(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
|
||||
|
||||
assertLocationAtPosition(doc, { line: 0, character: 0 }, { uri: notebook.cells[0].uri, line: 0, character: 0 });
|
||||
assertLocationAtPosition(doc, { line: 2, character: 0 }, { uri: notebook.cells[0].uri, line: 2, character: 0 });
|
||||
assertLocationAtPosition(doc, { line: 2, character: 12 }, { uri: notebook.cells[0].uri, line: 2, character: 12 });
|
||||
assertLocationAtPosition(doc, { line: 3, character: 0 }, { uri: notebook.cells[1].uri, line: 0, character: 0 });
|
||||
assertLocationAtPosition(doc, { line: 5, character: 0 }, { uri: notebook.cells[1].uri, line: 2, character: 0 });
|
||||
assertLocationAtPosition(doc, { line: 5, character: 11 }, { uri: notebook.cells[1].uri, line: 2, character: 11 });
|
||||
assertLocationAtPosition(doc, { line: 0, character: 0 }, { uri: notebook.notebookDocument.cells[0].uri, line: 0, character: 0 });
|
||||
assertLocationAtPosition(doc, { line: 2, character: 0 }, { uri: notebook.notebookDocument.cells[0].uri, line: 2, character: 0 });
|
||||
assertLocationAtPosition(doc, { line: 2, character: 12 }, { uri: notebook.notebookDocument.cells[0].uri, line: 2, character: 12 });
|
||||
assertLocationAtPosition(doc, { line: 3, character: 0 }, { uri: notebook.notebookDocument.cells[1].uri, line: 0, character: 0 });
|
||||
assertLocationAtPosition(doc, { line: 5, character: 0 }, { uri: notebook.notebookDocument.cells[1].uri, line: 2, character: 0 });
|
||||
assertLocationAtPosition(doc, { line: 5, character: 11 }, { uri: notebook.notebookDocument.cells[1].uri, line: 2, character: 11 });
|
||||
});
|
||||
|
||||
test('getText(range)', function () {
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
versionId: notebook.versionId + 1,
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
changes: [[0, 0, [{
|
||||
handle: 1,
|
||||
uri: CellUri.generate(notebook.uri, 1),
|
||||
@@ -491,11 +492,11 @@ suite('NotebookConcatDocument', function () {
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}]]]
|
||||
});
|
||||
}, false);
|
||||
|
||||
assert.equal(notebook.cells.length, 1 + 2); // markdown and code
|
||||
assert.equal(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
|
||||
|
||||
assert.equal(doc.getText(new Range(0, 0, 0, 0)), '');
|
||||
@@ -507,7 +508,7 @@ suite('NotebookConcatDocument', function () {
|
||||
|
||||
extHostNotebooks.$acceptModelChanged(notebookUri, {
|
||||
kind: NotebookCellsChangeType.ModelChange,
|
||||
versionId: notebook.versionId + 1,
|
||||
versionId: notebook.notebookDocument.version + 1,
|
||||
changes: [[0, 0, [{
|
||||
handle: 1,
|
||||
uri: CellUri.generate(notebook.uri, 1),
|
||||
@@ -525,11 +526,11 @@ suite('NotebookConcatDocument', function () {
|
||||
cellKind: CellKind.Code,
|
||||
outputs: [],
|
||||
}]]]
|
||||
});
|
||||
}, false);
|
||||
|
||||
assert.equal(notebook.cells.length, 1 + 2); // markdown and code
|
||||
assert.equal(notebook.notebookDocument.cells.length, 1 + 2); // markdown and code
|
||||
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook, undefined);
|
||||
let doc = new ExtHostNotebookConcatDocument(extHostNotebooks, extHostDocuments, notebook.notebookDocument, undefined);
|
||||
assertLines(doc, 'Hello', 'World', 'Hello World!', 'Hallo', 'Welt', 'Hallo Welt!');
|
||||
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import * as extHostTypes from 'vs/workbench/api/common/extHostTypes';
|
||||
import { MainContext, MainThreadTextEditorsShape, IWorkspaceEditDto } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { MainContext, MainThreadTextEditorsShape, IWorkspaceEditDto, WorkspaceEditType } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
import { SingleProxyRPCProtocol, TestRPCProtocol } from 'vs/workbench/test/browser/api/testRPCProtocol';
|
||||
import { ExtHostEditors } from 'vs/workbench/api/common/extHostTextEditors';
|
||||
import { WorkspaceTextEdit } from 'vs/editor/common/modes';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { assertType } from 'vs/base/common/types';
|
||||
|
||||
suite('ExtHostTextEditors.applyWorkspaceEdit', () => {
|
||||
|
||||
@@ -40,7 +40,7 @@ suite('ExtHostTextEditors.applyWorkspaceEdit', () => {
|
||||
EOL: '\n',
|
||||
}]
|
||||
});
|
||||
editors = new ExtHostEditors(rpcProtocol, documentsAndEditors);
|
||||
editors = new ExtHostEditors(rpcProtocol, documentsAndEditors, null!);
|
||||
});
|
||||
|
||||
test('uses version id if document available', async () => {
|
||||
@@ -48,7 +48,9 @@ suite('ExtHostTextEditors.applyWorkspaceEdit', () => {
|
||||
edit.replace(resource, new extHostTypes.Range(0, 0, 0, 0), 'hello');
|
||||
await editors.applyWorkspaceEdit(edit);
|
||||
assert.equal(workspaceResourceEdits.edits.length, 1);
|
||||
assert.equal((<WorkspaceTextEdit>workspaceResourceEdits.edits[0]).modelVersionId, 1337);
|
||||
const [first] = workspaceResourceEdits.edits;
|
||||
assertType(first._type === WorkspaceEditType.Text);
|
||||
assert.equal(first.modelVersionId, 1337);
|
||||
});
|
||||
|
||||
test('does not use version id if document is not available', async () => {
|
||||
@@ -56,7 +58,9 @@ suite('ExtHostTextEditors.applyWorkspaceEdit', () => {
|
||||
edit.replace(URI.parse('foo:bar2'), new extHostTypes.Range(0, 0, 0, 0), 'hello');
|
||||
await editors.applyWorkspaceEdit(edit);
|
||||
assert.equal(workspaceResourceEdits.edits.length, 1);
|
||||
assert.ok(typeof (<WorkspaceTextEdit>workspaceResourceEdits.edits[0]).modelVersionId === 'undefined');
|
||||
const [first] = workspaceResourceEdits.edits;
|
||||
assertType(first._type === WorkspaceEditType.Text);
|
||||
assert.ok(typeof first.modelVersionId === 'undefined');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -384,21 +384,21 @@ suite('ExtHostTypes', function () {
|
||||
edit.replace(URI.parse('foo:a'), new types.Range(2, 1, 2, 1), 'bar');
|
||||
edit.replace(URI.parse('foo:b'), new types.Range(3, 1, 3, 1), 'bazz');
|
||||
|
||||
const all = edit.allEntries();
|
||||
const all = edit._allEntries();
|
||||
assert.equal(all.length, 4);
|
||||
|
||||
const [first, second, third, fourth] = all;
|
||||
assertType(first._type === 2);
|
||||
assertType(first._type === types.FileEditType.Text);
|
||||
assert.equal(first.uri.toString(), 'foo:a');
|
||||
|
||||
assertType(second._type === 1);
|
||||
assertType(second._type === types.FileEditType.File);
|
||||
assert.equal(second.from!.toString(), 'foo:a');
|
||||
assert.equal(second.to!.toString(), 'foo:b');
|
||||
|
||||
assertType(third._type === 2);
|
||||
assertType(third._type === types.FileEditType.Text);
|
||||
assert.equal(third.uri.toString(), 'foo:a');
|
||||
|
||||
assertType(fourth._type === 2);
|
||||
assertType(fourth._type === types.FileEditType.Text);
|
||||
assert.equal(fourth.uri.toString(), 'foo:b');
|
||||
});
|
||||
|
||||
@@ -408,11 +408,11 @@ suite('ExtHostTypes', function () {
|
||||
edit.insert(uri, new types.Position(0, 0), 'Hello');
|
||||
edit.insert(uri, new types.Position(0, 0), 'Foo');
|
||||
|
||||
assert.equal(edit.allEntries().length, 2);
|
||||
let [first, second] = edit.allEntries();
|
||||
assert.equal(edit._allEntries().length, 2);
|
||||
let [first, second] = edit._allEntries();
|
||||
|
||||
assertType(first._type === 2);
|
||||
assertType(second._type === 2);
|
||||
assertType(first._type === types.FileEditType.Text);
|
||||
assertType(second._type === types.FileEditType.Text);
|
||||
assert.equal(first.edit.newText, 'Hello');
|
||||
assert.equal(second.edit.newText, 'Foo');
|
||||
});
|
||||
|
||||
@@ -8,12 +8,12 @@ import { URI } from 'vs/base/common/uri';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { MainThreadWebviews } from 'vs/workbench/api/browser/mainThreadWebview';
|
||||
import { MainThreadWebviewManager } from 'vs/workbench/api/browser/mainThreadWebviewManager';
|
||||
import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { NullApiDeprecationService } from 'vs/workbench/api/common/extHostApiDeprecationService';
|
||||
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||
import { ExtHostWebviews } from 'vs/workbench/api/common/extHostWebview';
|
||||
import { ExtHostWebviewSerializer } from 'vs/workbench/api/common/extHostWebviewSerializer';
|
||||
import { ExtHostWebviewPanels } from 'vs/workbench/api/common/extHostWebviewPanels';
|
||||
import { EditorViewColumn } from 'vs/workbench/api/common/shared/editor';
|
||||
import type * as vscode from 'vscode';
|
||||
import { SingleProxyRPCProtocol } from './testRPCProtocol';
|
||||
@@ -36,7 +36,7 @@ suite('ExtHostWebview', () => {
|
||||
isExtensionDevelopmentDebug: false,
|
||||
}, undefined, new NullLogService(), NullApiDeprecationService);
|
||||
|
||||
const extHostWebviewSerializer = new ExtHostWebviewSerializer(rpcProtocol!, extHostWebviews);
|
||||
const extHostWebviewPanels = new ExtHostWebviewPanels(rpcProtocol!, extHostWebviews, undefined);
|
||||
|
||||
let lastInvokedDeserializer: vscode.WebviewPanelSerializer | undefined = undefined;
|
||||
|
||||
@@ -51,20 +51,20 @@ suite('ExtHostWebview', () => {
|
||||
const serializerA = new NoopSerializer();
|
||||
const serializerB = new NoopSerializer();
|
||||
|
||||
const serializerARegistration = extHostWebviewSerializer.registerWebviewPanelSerializer(extension, viewType, serializerA);
|
||||
const serializerARegistration = extHostWebviewPanels.registerWebviewPanelSerializer(extension, viewType, serializerA);
|
||||
|
||||
await extHostWebviewSerializer.$deserializeWebviewPanel('x', viewType, 'title', {}, 0 as EditorViewColumn, {});
|
||||
await extHostWebviewPanels.$deserializeWebviewPanel('x', viewType, 'title', {}, 0 as EditorViewColumn, {});
|
||||
assert.strictEqual(lastInvokedDeserializer, serializerA);
|
||||
|
||||
assert.throws(
|
||||
() => extHostWebviewSerializer.registerWebviewPanelSerializer(extension, viewType, serializerB),
|
||||
() => extHostWebviewPanels.registerWebviewPanelSerializer(extension, viewType, serializerB),
|
||||
'Should throw when registering two serializers for the same view');
|
||||
|
||||
serializerARegistration.dispose();
|
||||
|
||||
extHostWebviewSerializer.registerWebviewPanelSerializer(extension, viewType, serializerB);
|
||||
extHostWebviewPanels.registerWebviewPanelSerializer(extension, viewType, serializerB);
|
||||
|
||||
await extHostWebviewSerializer.$deserializeWebviewPanel('x', viewType, 'title', {}, 0 as EditorViewColumn, {});
|
||||
await extHostWebviewPanels.$deserializeWebviewPanel('x', viewType, 'title', {}, 0 as EditorViewColumn, {});
|
||||
assert.strictEqual(lastInvokedDeserializer, serializerB);
|
||||
});
|
||||
|
||||
@@ -74,7 +74,10 @@ suite('ExtHostWebview', () => {
|
||||
webviewResourceRoot: 'vscode-resource://{{resource}}',
|
||||
isExtensionDevelopmentDebug: false,
|
||||
}, undefined, new NullLogService(), NullApiDeprecationService);
|
||||
const webview = extHostWebviews.createWebviewPanel({} as any, 'type', 'title', 1, {});
|
||||
|
||||
const extHostWebviewPanels = new ExtHostWebviewPanels(rpcProtocol!, extHostWebviews, undefined);
|
||||
|
||||
const webview = extHostWebviewPanels.createWebviewPanel({} as any, 'type', 'title', 1, {});
|
||||
|
||||
assert.strictEqual(
|
||||
webview.webview.asWebviewUri(URI.parse('file:///Users/codey/file.html')).toString(),
|
||||
@@ -113,7 +116,10 @@ suite('ExtHostWebview', () => {
|
||||
webviewResourceRoot: `https://{{uuid}}.webview.contoso.com/commit/{{resource}}`,
|
||||
isExtensionDevelopmentDebug: false,
|
||||
}, undefined, new NullLogService(), NullApiDeprecationService);
|
||||
const webview = extHostWebviews.createWebviewPanel({} as any, 'type', 'title', 1, {});
|
||||
|
||||
const extHostWebviewPanels = new ExtHostWebviewPanels(rpcProtocol!, extHostWebviews, undefined);
|
||||
|
||||
const webview = extHostWebviewPanels.createWebviewPanel({} as any, 'type', 'title', 1, {});
|
||||
|
||||
function stripEndpointUuid(input: string) {
|
||||
return input.replace(/^https:\/\/[^\.]+?\./, '');
|
||||
@@ -153,7 +159,7 @@ suite('ExtHostWebview', () => {
|
||||
|
||||
|
||||
function createNoopMainThreadWebviews() {
|
||||
return new class extends mock<MainThreadWebviews>() {
|
||||
return new class extends mock<MainThreadWebviewManager>() {
|
||||
$createWebviewPanel() { /* noop */ }
|
||||
$registerSerializer() { /* noop */ }
|
||||
$unregisterSerializer() { /* noop */ }
|
||||
|
||||
@@ -10,7 +10,7 @@ import { TestConfigurationService } from 'vs/platform/configuration/test/common/
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { TestCodeEditorService } from 'vs/editor/test/browser/editorTestServices';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { ExtHostDocumentsAndEditorsShape, ExtHostContext, ExtHostDocumentsShape, IWorkspaceTextEditDto } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostDocumentsAndEditorsShape, ExtHostContext, ExtHostDocumentsShape, IWorkspaceTextEditDto, WorkspaceEditType } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { mock } from 'vs/base/test/common/mock';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { MainThreadTextEditors } from 'vs/workbench/api/browser/mainThreadEditors';
|
||||
@@ -20,7 +20,7 @@ import { Position } from 'vs/editor/common/core/position';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { TestFileService, TestEditorService, TestEditorGroupsService, TestEnvironmentService } from 'vs/workbench/test/browser/workbenchTestServices';
|
||||
import { BulkEditService } from 'vs/workbench/services/bulkEdit/browser/bulkEditService';
|
||||
import { BulkEditService } from 'vs/workbench/contrib/bulkEdit/browser/bulkEditService';
|
||||
import { NullLogService, ILogService } from 'vs/platform/log/common/log';
|
||||
import { ITextModelService, IResolvedTextEditorModel } from 'vs/editor/common/services/resolverService';
|
||||
import { IReference, ImmortalReference } from 'vs/base/common/lifecycle';
|
||||
@@ -170,6 +170,7 @@ suite('MainThreadEditors', () => {
|
||||
let model = modelService.createModel('something', null, resource);
|
||||
|
||||
let workspaceResourceEdit: IWorkspaceTextEditDto = {
|
||||
_type: WorkspaceEditType.Text,
|
||||
resource: resource,
|
||||
modelVersionId: model.getVersionId(),
|
||||
edit: {
|
||||
@@ -191,6 +192,7 @@ suite('MainThreadEditors', () => {
|
||||
let model = modelService.createModel('something', null, resource);
|
||||
|
||||
let workspaceResourceEdit1: IWorkspaceTextEditDto = {
|
||||
_type: WorkspaceEditType.Text,
|
||||
resource: resource,
|
||||
modelVersionId: model.getVersionId(),
|
||||
edit: {
|
||||
@@ -199,6 +201,7 @@ suite('MainThreadEditors', () => {
|
||||
}
|
||||
};
|
||||
let workspaceResourceEdit2: IWorkspaceTextEditDto = {
|
||||
_type: WorkspaceEditType.Text,
|
||||
resource: resource,
|
||||
modelVersionId: model.getVersionId(),
|
||||
edit: {
|
||||
@@ -221,9 +224,9 @@ suite('MainThreadEditors', () => {
|
||||
test(`applyWorkspaceEdit with only resource edit`, () => {
|
||||
return editors.$tryApplyWorkspaceEdit({
|
||||
edits: [
|
||||
{ oldUri: resource, newUri: resource, options: undefined },
|
||||
{ oldUri: undefined, newUri: resource, options: undefined },
|
||||
{ oldUri: resource, newUri: undefined, options: undefined }
|
||||
{ _type: WorkspaceEditType.File, oldUri: resource, newUri: resource, options: undefined },
|
||||
{ _type: WorkspaceEditType.File, oldUri: undefined, newUri: resource, options: undefined },
|
||||
{ _type: WorkspaceEditType.File, oldUri: resource, newUri: undefined, options: undefined }
|
||||
]
|
||||
}).then((result) => {
|
||||
assert.equal(result, true);
|
||||
|
||||
@@ -464,8 +464,9 @@ suite('Workbench editor groups', () => {
|
||||
|
||||
// Active && Pinned
|
||||
const input1 = input();
|
||||
const openedEditor = group.openEditor(input1, { active: true, pinned: true });
|
||||
const { editor: openedEditor, isNew } = group.openEditor(input1, { active: true, pinned: true });
|
||||
assert.equal(openedEditor, input1);
|
||||
assert.equal(isNew, true);
|
||||
|
||||
assert.equal(group.count, 1);
|
||||
assert.equal(group.getEditors(EditorsOrder.MOST_RECENTLY_ACTIVE).length, 1);
|
||||
@@ -575,11 +576,13 @@ suite('Workbench editor groups', () => {
|
||||
const input3 = input('3');
|
||||
|
||||
// Pinned and Active
|
||||
let openedEditor = group.openEditor(input1, { pinned: true, active: true });
|
||||
assert.equal(openedEditor, input1);
|
||||
let openedEditorResult = group.openEditor(input1, { pinned: true, active: true });
|
||||
assert.equal(openedEditorResult.editor, input1);
|
||||
assert.equal(openedEditorResult.isNew, true);
|
||||
|
||||
openedEditor = group.openEditor(input1Copy, { pinned: true, active: true }); // opening copy of editor should still return existing one
|
||||
assert.equal(openedEditor, input1);
|
||||
openedEditorResult = group.openEditor(input1Copy, { pinned: true, active: true }); // opening copy of editor should still return existing one
|
||||
assert.equal(openedEditorResult.editor, input1);
|
||||
assert.equal(openedEditorResult.isNew, false);
|
||||
|
||||
group.openEditor(input2, { pinned: true, active: true });
|
||||
group.openEditor(input3, { pinned: true, active: true });
|
||||
@@ -1145,7 +1148,7 @@ suite('Workbench editor groups', () => {
|
||||
|
||||
// [] -> /index.html/
|
||||
const indexHtml = input('index.html');
|
||||
let openedEditor = group.openEditor(indexHtml);
|
||||
let openedEditor = group.openEditor(indexHtml).editor;
|
||||
assert.equal(openedEditor, indexHtml);
|
||||
assert.equal(group.activeEditor, indexHtml);
|
||||
assert.equal(group.previewEditor, indexHtml);
|
||||
@@ -1154,7 +1157,7 @@ suite('Workbench editor groups', () => {
|
||||
|
||||
// /index.html/ -> /index.html/
|
||||
const sameIndexHtml = input('index.html');
|
||||
openedEditor = group.openEditor(sameIndexHtml);
|
||||
openedEditor = group.openEditor(sameIndexHtml).editor;
|
||||
assert.equal(openedEditor, indexHtml);
|
||||
assert.equal(group.activeEditor, indexHtml);
|
||||
assert.equal(group.previewEditor, indexHtml);
|
||||
@@ -1163,7 +1166,7 @@ suite('Workbench editor groups', () => {
|
||||
|
||||
// /index.html/ -> /style.css/
|
||||
const styleCss = input('style.css');
|
||||
openedEditor = group.openEditor(styleCss);
|
||||
openedEditor = group.openEditor(styleCss).editor;
|
||||
assert.equal(openedEditor, styleCss);
|
||||
assert.equal(group.activeEditor, styleCss);
|
||||
assert.equal(group.previewEditor, styleCss);
|
||||
@@ -1172,7 +1175,7 @@ suite('Workbench editor groups', () => {
|
||||
|
||||
// /style.css/ -> [/style.css/, test.js]
|
||||
const testJs = input('test.js');
|
||||
openedEditor = group.openEditor(testJs, { active: true, pinned: true });
|
||||
openedEditor = group.openEditor(testJs, { active: true, pinned: true }).editor;
|
||||
assert.equal(openedEditor, testJs);
|
||||
assert.equal(group.previewEditor, styleCss);
|
||||
assert.equal(group.activeEditor, testJs);
|
||||
|
||||
@@ -60,9 +60,11 @@ suite('Workbench editor model', () => {
|
||||
|
||||
const model = await m.load();
|
||||
assert(model === m);
|
||||
assert.equal(model.isDisposed(), false);
|
||||
assert.strictEqual(m.isResolved(), true);
|
||||
m.dispose();
|
||||
assert.equal(counter, 1);
|
||||
assert.equal(model.isDisposed(), true);
|
||||
});
|
||||
|
||||
test('BaseTextEditorModel', async () => {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { BaseEditor, EditorMemento } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
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';
|
||||
@@ -27,7 +27,7 @@ const NullThemeService = new TestThemeService();
|
||||
let EditorRegistry: IEditorRegistry = Platform.Registry.as(Extensions.Editors);
|
||||
let EditorInputRegistry: IEditorInputFactoryRegistry = Platform.Registry.as(EditorExtensions.EditorInputFactories);
|
||||
|
||||
export class MyEditor extends BaseEditor {
|
||||
export class MyEditor extends EditorPane {
|
||||
|
||||
constructor(@ITelemetryService telemetryService: ITelemetryService) {
|
||||
super('MyEditor', NullTelemetryService, NullThemeService, new TestStorageService());
|
||||
@@ -38,7 +38,7 @@ export class MyEditor extends BaseEditor {
|
||||
createEditor(): any { }
|
||||
}
|
||||
|
||||
export class MyOtherEditor extends BaseEditor {
|
||||
export class MyOtherEditor extends EditorPane {
|
||||
|
||||
constructor(@ITelemetryService telemetryService: ITelemetryService) {
|
||||
super('myOtherEditor', NullTelemetryService, NullThemeService, new TestStorageService());
|
||||
@@ -96,9 +96,9 @@ class MyOtherInput extends EditorInput {
|
||||
}
|
||||
class MyResourceEditorInput extends ResourceEditorInput { }
|
||||
|
||||
suite('Workbench base editor', () => {
|
||||
suite('Workbench EditorPane', () => {
|
||||
|
||||
test('BaseEditor API', async () => {
|
||||
test('EditorPane API', async () => {
|
||||
let e = new MyEditor(NullTelemetryService);
|
||||
let input = new MyOtherInput();
|
||||
let options = new EditorOptions();
|
||||
@@ -106,7 +106,7 @@ suite('Workbench base editor', () => {
|
||||
assert(!e.isVisible());
|
||||
assert(!e.input);
|
||||
|
||||
await e.setInput(input, options, CancellationToken.None);
|
||||
await e.setInput(input, options, Object.create(null), CancellationToken.None);
|
||||
assert.strictEqual(input, e.input);
|
||||
const group = new TestEditorGroupView(1);
|
||||
e.setVisible(true, group);
|
||||
@@ -10,7 +10,7 @@ import * as resources 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 } from 'vs/workbench/common/editor';
|
||||
import { IEditorInputWithOptions, IEditorIdentifier, IUntitledTextResourceEditorInput, IResourceDiffEditorInput, IEditorInput, IEditorPane, IEditorCloseEvent, IEditorPartOptions, IRevertOptions, GroupIdentifier, EditorInput, EditorOptions, EditorsOrder, IFileEditorInput, IEditorInputFactoryRegistry, IEditorInputFactory, Extensions as EditorExtensions, ISaveOptions, IMoveResult, ITextEditorPane, ITextDiffEditorPane, IVisibleEditorPane, IEditorOpenContext } from 'vs/workbench/common/editor';
|
||||
import { IEditorOpeningEvent, EditorServiceImpl, IEditorGroupView, IEditorGroupsAccessor } from 'vs/workbench/browser/parts/editor/editor';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { IBackupFileService, IResolvedBackup } from 'vs/workbench/services/backup/common/backup';
|
||||
@@ -91,7 +91,7 @@ import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
|
||||
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
|
||||
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { TestDialogService } from 'vs/platform/dialogs/test/common/testDialogService';
|
||||
@@ -429,6 +429,7 @@ export class TestLayoutService implements IWorkbenchLayoutService {
|
||||
hasFocus(_part: Parts): boolean { return false; }
|
||||
focusPart(_part: Parts): void { }
|
||||
hasWindowBorder(): boolean { return false; }
|
||||
getWindowBorderWidth(): number { return 0; }
|
||||
getWindowBorderRadius(): string | undefined { return undefined; }
|
||||
isVisible(_part: Parts): boolean { return true; }
|
||||
getDimension(_part: Parts): Dimension { return new Dimension(0, 0); }
|
||||
@@ -1031,7 +1032,7 @@ export class TestHostService implements IHostService {
|
||||
async restart(): Promise<void> { }
|
||||
async reload(): Promise<void> { }
|
||||
|
||||
async focus(): Promise<void> { }
|
||||
async focus(options?: { force: boolean }): Promise<void> { }
|
||||
|
||||
async openWindow(arg1?: IOpenEmptyWindowOptions | IWindowOpenable[], arg2?: IOpenWindowOptions): Promise<void> { }
|
||||
|
||||
@@ -1068,12 +1069,12 @@ export class TestEditorInput extends EditorInput {
|
||||
}
|
||||
|
||||
export function registerTestEditor(id: string, inputs: SyncDescriptor<EditorInput>[], factoryInputId?: string): IDisposable {
|
||||
class TestEditorControl extends BaseEditor {
|
||||
class TestEditor extends EditorPane {
|
||||
|
||||
constructor() { super(id, NullTelemetryService, new TestThemeService(), new TestStorageService()); }
|
||||
|
||||
async setInput(input: EditorInput, options: EditorOptions | undefined, token: CancellationToken): Promise<void> {
|
||||
super.setInput(input, options, token);
|
||||
async setInput(input: EditorInput, options: EditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken): Promise<void> {
|
||||
super.setInput(input, options, context, token);
|
||||
|
||||
await input.resolve();
|
||||
}
|
||||
@@ -1085,7 +1086,7 @@ export function registerTestEditor(id: string, inputs: SyncDescriptor<EditorInpu
|
||||
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
disposables.add(Registry.as<IEditorRegistry>(Extensions.Editors).registerEditor(EditorDescriptor.create(TestEditorControl, id, 'Test Editor Control'), inputs));
|
||||
disposables.add(Registry.as<IEditorRegistry>(Extensions.Editors).registerEditor(EditorDescriptor.create(TestEditor, id, 'Test Editor Control'), inputs));
|
||||
|
||||
if (factoryInputId) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user