Skip to content

Commit 10fca7b

Browse files
authored
Merge pull request RooCodeInc#1501 from RooVetGit/strip_all_boms
Strip all BOMs
2 parents 3806ea9 + 585d5ab commit 10fca7b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/integrations/editor/DiffViewProvider.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class DiffViewProvider {
105105
const edit = new vscode.WorkspaceEdit()
106106
const rangeToReplace = new vscode.Range(0, 0, endLine + 1, 0)
107107
const contentToReplace = accumulatedLines.slice(0, endLine + 1).join("\n") + "\n"
108-
edit.replace(document.uri, rangeToReplace, stripBom(stripBom(contentToReplace)))
108+
edit.replace(document.uri, rangeToReplace, this.stripAllBOMs(contentToReplace))
109109
await vscode.workspace.applyEdit(edit)
110110
// Update decorations
111111
this.activeLineController.setActiveLine(endLine)
@@ -132,7 +132,7 @@ export class DiffViewProvider {
132132
finalEdit.replace(
133133
document.uri,
134134
new vscode.Range(0, 0, document.lineCount, 0),
135-
stripBom(stripBom(accumulatedContent)),
135+
this.stripAllBOMs(accumulatedContent),
136136
)
137137
await vscode.workspace.applyEdit(finalEdit)
138138
// Clear all decorations at the end (after applying final edit)
@@ -341,6 +341,16 @@ export class DiffViewProvider {
341341
}
342342
}
343343

344+
private stripAllBOMs(input: string): string {
345+
let result = input
346+
let previous
347+
do {
348+
previous = result
349+
result = stripBom(result)
350+
} while (result !== previous)
351+
return result
352+
}
353+
344354
// close editor if open?
345355
async reset() {
346356
this.editType = undefined

0 commit comments

Comments
 (0)