Skip to content

Commit

Permalink
Couldn't create new files (fix #240210) (#240338)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero authored Feb 11, 2025
1 parent 21525b0 commit 1fa9d37
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/vs/workbench/services/textfile/common/encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,17 @@ async function guessEncodingByBuffer(buffer: VSBuffer, candidateGuessEncodings?:
}
}

let guessed: { encoding: string };
let guessed: { encoding: string | undefined } | undefined;
try {
guessed = jschardet.detect(binaryString, candidateGuessEncodings ? { detectEncodings: candidateGuessEncodings } : undefined);
} catch (error) {
return null; // jschardet throws for unknown encodings (https://github.com/microsoft/vscode/issues/239928)
}

if (!guessed || !guessed.encoding) {
return null;
}

const enc = guessed.encoding.toLowerCase();
if (0 <= IGNORE_ENCODINGS.indexOf(enc)) {
return null; // see comment above why we ignore some encodings
Expand Down

0 comments on commit 1fa9d37

Please sign in to comment.