Support setting encoding from extension (fix #251188) (#251195)

This commit is contained in:
Benjamin Pasero
2025-06-11 12:15:35 +02:00
committed by GitHub
parent 0ac8174fbc
commit 13d49873b7
2 changed files with 11 additions and 0 deletions

View File

@@ -1399,6 +1399,14 @@ suite('vscode API - workspace', () => {
assert.strictEqual(doc2.encoding, 'cp1252');
});
test('encoding: openTextDocument - can change the encoding of an existing untitled document', async () => {
const doc = await vscode.workspace.openTextDocument({ content: 'Hello World' });
assert.strictEqual(doc.encoding, 'utf8');
await vscode.workspace.openTextDocument(doc.uri, { encoding: 'windows1252' });
assert.strictEqual(doc.encoding, 'windows1252');
});
test('encoding: decode', async function () {
const uri = root.with({ path: posix.join(root.path, 'file.txt') });