make sure the API doesn't allow to set an empty selections array (#251010)

re https://github.com/microsoft/vscode-copilot/issues/18075
This commit is contained in:
Johannes Rieken
2025-06-09 17:23:22 +02:00
committed by GitHub
parent a3beb7acb9
commit 1a2bacb0a0
2 changed files with 18 additions and 0 deletions

View File

@@ -295,4 +295,19 @@ suite('vscode API - editors', () => {
assert.strictEqual(document.getText(), Buffer.from(await workspace.fs.readFile(file)).toString());
}
test('extEditor.selection can be empty #18075', async function () {
await withRandomFileEditor('foo', async editor => {
assert.ok(editor.selections.length > 0);
editor.selections = [];
assert.strictEqual(editor.selections.length, 1);
assert.strictEqual(editor.selections[0].start.line, 0);
assert.strictEqual(editor.selections[0].start.character, 0);
assert.strictEqual(editor.selections[0].end.line, 0);
assert.strictEqual(editor.selections[0].end.character, 0);
});
});
});