fix: character encoding corruption when executing the /copy command on Windows. (#1069)

Co-authored-by: linda <hxn@163.com>
This commit is contained in:
citlalinda
2025-11-20 10:23:17 +08:00
committed by GitHub
parent 3c64f7bff5
commit e1f793b2e0
2 changed files with 23 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ import {
isSlashCommand,
copyToClipboard,
getUrlOpenCommand,
CodePage,
} from './commandUtils.js';
// Mock child_process
@@ -188,7 +189,10 @@ describe('commandUtils', () => {
await copyToClipboard(testText);
expect(mockSpawn).toHaveBeenCalledWith('clip', []);
expect(mockSpawn).toHaveBeenCalledWith('cmd', [
'/c',
`chcp ${CodePage.UTF8} >nul && clip`,
]);
expect(mockChild.stdin.write).toHaveBeenCalledWith(testText);
expect(mockChild.stdin.end).toHaveBeenCalled();
});