mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-10 10:12:34 -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);
|
||||
|
||||
Reference in New Issue
Block a user