mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-30 12:40:44 +00:00
feat: Preserve UTF-8 BOM when editing files (Fix #1672)
- Add FileEncoding constants (UTF8, UTF8_BOM) - Add detectFileBOM() to detect existing file encoding - Modify writeTextFile() to support BOM option - Add defaultFileEncoding configuration option - Preserve BOM when editing existing files - Use configured encoding for new files - Add comprehensive tests (unit, integration, e2e) - Update documentation Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
bd900d3668
commit
831d74dbfe
11 changed files with 472 additions and 16 deletions
|
|
@ -10,6 +10,7 @@ import {
|
|||
Config,
|
||||
DEFAULT_QWEN_EMBEDDING_MODEL,
|
||||
FileDiscoveryService,
|
||||
FileEncoding,
|
||||
getCurrentGeminiMdFilename,
|
||||
loadServerHierarchicalMemory,
|
||||
setGeminiMdFilename as setServerGeminiMdFilename,
|
||||
|
|
@ -1030,6 +1031,8 @@ export async function loadCliConfig(
|
|||
// always be true and the settings file can never disable recording.
|
||||
chatRecording:
|
||||
argv.chatRecording ?? settings.general?.chatRecording ?? true,
|
||||
defaultFileEncoding:
|
||||
settings.general?.defaultFileEncoding ?? FileEncoding.UTF8,
|
||||
lsp: {
|
||||
enabled: lspEnabled,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -244,6 +244,20 @@ const SETTINGS_SCHEMA = {
|
|||
'Enable saving chat history to disk. Disabling this will also prevent --continue and --resume from working.',
|
||||
showInDialog: false,
|
||||
},
|
||||
defaultFileEncoding: {
|
||||
type: 'enum',
|
||||
label: 'Default File Encoding',
|
||||
category: 'General',
|
||||
requiresRestart: false,
|
||||
default: 'utf-8',
|
||||
description:
|
||||
'Default encoding for new files. Use "utf-8" (default) for UTF-8 without BOM, or "utf-8-bom" for UTF-8 with BOM. Only change this if your project specifically requires BOM.',
|
||||
showInDialog: false,
|
||||
options: [
|
||||
{ value: 'utf-8', label: 'UTF-8 (without BOM)' },
|
||||
{ value: 'utf-8-bom', label: 'UTF-8 with BOM' },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
output: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue