Add test for BOM character preservation in VSBuffer (issue #251527) (#277608)

* Initial plan

* Add test for issue #251527 - BOM character preservation in VSBuffer

Co-authored-by: bpasero <900690+bpasero@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bpasero <900690+bpasero@users.noreply.github.com>
This commit is contained in:
Copilot
2025-11-17 06:16:26 +00:00
committed by GitHub
parent ddaae0e602
commit fafe725235

View File

@@ -19,6 +19,20 @@ suite('Buffer', () => {
assert.deepStrictEqual(buffer.toString(), 'hi');
});
test('issue #251527 - VSBuffer#toString preserves BOM character in filenames', () => {
// BOM character (U+FEFF) is a zero-width character that was being stripped
// when deserializing messages in the IPC layer. This test verifies that
// the BOM character is preserved when using VSBuffer.toString().
const bomChar = '\uFEFF';
const filename = `${bomChar}c.txt`;
const buffer = VSBuffer.fromString(filename);
const result = buffer.toString();
// Verify the BOM character is preserved
assert.strictEqual(result, filename);
assert.strictEqual(result.charCodeAt(0), 0xFEFF);
});
test('bufferToReadable / readableToBuffer', () => {
const content = 'Hello World';
const readable = bufferToReadable(VSBuffer.fromString(content));