Skip to content

Commit 48add1e

Browse files
committed
More fixes
1 parent 74db182 commit 48add1e

File tree

1 file changed

+34
-20
lines changed

1 file changed

+34
-20
lines changed

src/test/datascience/notebook/helper.ts

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,22 @@ export async function insertMarkdownCell(source: string) {
5050
assert.fail('No active editor');
5151
return;
5252
}
53-
new WorkspaceEdit().replaceCells(activeEditor.document.uri, activeEditor.document.cells.length, 0, [
54-
{
55-
cellKind: vscodeNotebookEnums.CellKind.Markdown,
56-
language: MARKDOWN_LANGUAGE,
57-
source,
58-
metadata: {},
59-
outputs: []
60-
}
61-
]);
53+
new WorkspaceEdit().replaceCells(
54+
activeEditor.document.uri,
55+
activeEditor.document.cells.length - 1,
56+
activeEditor.document.cells.length - 1,
57+
[
58+
{
59+
cellKind: vscodeNotebookEnums.CellKind.Markdown,
60+
language: MARKDOWN_LANGUAGE,
61+
source,
62+
metadata: {
63+
hasExecutionOrder: false
64+
},
65+
outputs: []
66+
}
67+
]
68+
);
6269

6370
await waitForCondition(
6471
async () =>
@@ -75,15 +82,22 @@ export async function insertPythonCell(source: string) {
7582
assert.fail('No active editor');
7683
return;
7784
}
78-
new WorkspaceEdit().replaceCells(activeEditor.document.uri, activeEditor.document.cells.length, 0, [
79-
{
80-
cellKind: vscodeNotebookEnums.CellKind.Code,
81-
language: PYTHON_LANGUAGE,
82-
source,
83-
metadata: {},
84-
outputs: []
85-
}
86-
]);
85+
new WorkspaceEdit().replaceCells(
86+
activeEditor.document.uri,
87+
activeEditor.document.cells.length - 1,
88+
activeEditor.document.cells.length - 1,
89+
[
90+
{
91+
cellKind: vscodeNotebookEnums.CellKind.Code,
92+
language: PYTHON_LANGUAGE,
93+
source,
94+
metadata: {
95+
hasExecutionOrder: false
96+
},
97+
outputs: []
98+
}
99+
]
100+
);
87101
await waitForCondition(
88102
async () =>
89103
activeEditor?.document.cells[activeEditor.document.cells.length - 1].document.getText().trim() ===
@@ -108,15 +122,15 @@ export async function deleteCell(index: number = 0) {
108122
assert.fail('No active editor');
109123
return;
110124
}
111-
new WorkspaceEdit().replaceCells(activeEditor.document.uri, index, 1, []);
125+
new WorkspaceEdit().replaceCells(activeEditor.document.uri, index, index, []);
112126
}
113127
export async function deleteAllCellsAndWait() {
114128
const { vscodeNotebook } = await getServices();
115129
const activeEditor = vscodeNotebook.activeNotebookEditor;
116130
if (!activeEditor || activeEditor.document.cells.length === 0) {
117131
return;
118132
}
119-
new WorkspaceEdit().replaceCells(activeEditor.document.uri, 0, activeEditor.document.cells.length, []);
133+
new WorkspaceEdit().replaceCells(activeEditor.document.uri, 0, activeEditor.document.cells.length - 1, []);
120134
// Wait for cell to get deleted.
121135
await waitForCondition(async () => activeEditor.document.cells.length === 0, 1_000, 'Cell not deleted');
122136
}

0 commit comments

Comments
 (0)