Skip to content

Commit 4831ed0

Browse files
committed
fix: prevent YAML line breaks by setting lineWidth to 0
- Added lineWidth: 0 option to all yaml.stringify() calls - Prevents automatic line wrapping at 80 characters - Improves readability of YAML output for long strings - Applied to CustomModesManager, SimpleInstaller, and migrateSettings
1 parent 7d8861d commit 4831ed0

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/core/config/CustomModesManager.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export class CustomModesManager {
213213
const fileExists = await fileExistsAtPath(filePath)
214214

215215
if (!fileExists) {
216-
await this.queueWrite(() => fs.writeFile(filePath, yaml.stringify({ customModes: [] })))
216+
await this.queueWrite(() => fs.writeFile(filePath, yaml.stringify({ customModes: [] }, { lineWidth: 0 })))
217217
}
218218

219219
return filePath
@@ -418,7 +418,7 @@ export class CustomModesManager {
418418
content = await fs.readFile(filePath, "utf-8")
419419
} catch (error) {
420420
// File might not exist yet.
421-
content = yaml.stringify({ customModes: [] })
421+
content = yaml.stringify({ customModes: [] }, { lineWidth: 0 })
422422
}
423423

424424
let settings
@@ -431,7 +431,7 @@ export class CustomModesManager {
431431
}
432432

433433
settings.customModes = operation(settings.customModes || [])
434-
await fs.writeFile(filePath, yaml.stringify(settings), "utf-8")
434+
await fs.writeFile(filePath, yaml.stringify(settings, { lineWidth: 0 }), "utf-8")
435435
}
436436

437437
private async refreshMergedState(): Promise<void> {
@@ -490,7 +490,7 @@ export class CustomModesManager {
490490
public async resetCustomModes(): Promise<void> {
491491
try {
492492
const filePath = await this.getCustomModesFilePath()
493-
await fs.writeFile(filePath, yaml.stringify({ customModes: [] }))
493+
await fs.writeFile(filePath, yaml.stringify({ customModes: [] }, { lineWidth: 0 }))
494494
await this.context.globalState.update("customModes", [])
495495
this.clearCache()
496496
await this.onUpdate()

src/services/marketplace/SimpleInstaller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class SimpleInstaller {
8484

8585
// Write back to file
8686
await fs.mkdir(path.dirname(filePath), { recursive: true })
87-
const yamlContent = yaml.stringify(existingData)
87+
const yamlContent = yaml.stringify(existingData, { lineWidth: 0 })
8888
await fs.writeFile(filePath, yamlContent, "utf-8")
8989

9090
// Calculate approximate line number where the new mode was added
@@ -282,7 +282,7 @@ export class SimpleInstaller {
282282
existingData.customModes = existingData.customModes.filter((mode: any) => mode.slug !== modeData.slug)
283283

284284
// Always write back the file, even if empty
285-
await fs.writeFile(filePath, yaml.stringify(existingData), "utf-8")
285+
await fs.writeFile(filePath, yaml.stringify(existingData, { lineWidth: 0 }), "utf-8")
286286
}
287287
} catch (error: any) {
288288
if (error.code === "ENOENT") {

src/utils/migrateSettings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ async function migrateCustomModesToYaml(settingsDir: string, outputChannel: vsco
9292
// Parse JSON to object (using the yaml library just to be safe/consistent)
9393
const customModesData = yaml.parse(jsonContent)
9494

95-
// Convert to YAML
96-
const yamlContent = yaml.stringify(customModesData)
95+
// Convert to YAML with no line width limit to prevent line breaks
96+
const yamlContent = yaml.stringify(customModesData, { lineWidth: 0 })
9797

9898
// Write YAML file
9999
await fs.writeFile(newYamlPath, yamlContent, "utf-8")

0 commit comments

Comments
 (0)