mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-05 15:31:27 +00:00
fix: Address review comments for BOM encoding support
- Edit tool now respects defaultFileEncoding for new files - Edit tool preserves BOM character for existing files without re-adding - AcpFileSystemService detects BOM through ACP client with fallback - Use line: null, limit: 1 for efficient BOM detection - Add unit tests for AcpFileSystemService.detectFileBOM - Add unit tests for EditTool BOM handling Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
831d74dbfe
commit
2d525d9fd0
4 changed files with 195 additions and 4 deletions
|
|
@ -74,7 +74,22 @@ export class AcpFileSystemService implements FileSystemService {
|
|||
}
|
||||
|
||||
async detectFileBOM(filePath: string): Promise<boolean> {
|
||||
// Always use fallback for BOM detection
|
||||
// Try to detect BOM through ACP client first by reading first line
|
||||
if (this.capabilities.readTextFile) {
|
||||
try {
|
||||
const response = await this.client.readTextFile({
|
||||
path: filePath,
|
||||
sessionId: this.sessionId,
|
||||
line: null,
|
||||
limit: 1,
|
||||
});
|
||||
// Check if content starts with BOM character (U+FEFF)
|
||||
return response.content.charCodeAt(0) === 0xfeff;
|
||||
} catch {
|
||||
// Fall through to fallback if ACP read fails
|
||||
}
|
||||
}
|
||||
// Fall back to local filesystem detection
|
||||
return this.fallback.detectFileBOM(filePath);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue