Skip to content

Commit

Permalink
files.autoGuessEncoding doesn't always work for files opened during v…
Browse files Browse the repository at this point in the history
…scode startup (fix #225135) (#225217)
  • Loading branch information
bpasero authored Aug 9, 2024
1 parent 4693ac3 commit c588860
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1104,8 +1104,8 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil

this.logService.info(`Adjusting encoding based on configured language override to '${encoding}' for ${this.resource.toString(true)}.`);

// Re-open with new encoding
return this.setEncodingInternal(encoding, EncodingMode.Decode);
// Force resolve to pick up the new encoding
return this.forceResolveFromFile();
}

private hasEncodingSetExplicitly: boolean = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,7 @@ suite('Files - TextFileEditorModel', () => {

model.setLanguageId(languageId);

await deferredPromise.p;

assert.strictEqual(model.getEncoding(), UTF16be);
await deferredPromise.p; // this asserts that the model was reloaded due to the language change
});

test('create with language', async function () {
Expand Down

0 comments on commit c588860

Please sign in to comment.