Use TextDecoder instead of Buffer

Fixes #129165
This commit is contained in:
Matt Bierner 2021-07-22 13:36:04 -07:00
parent 53ca7186cc
commit ff922dc231
No known key found for this signature in database
GPG key ID: 099C331567E11888

View file

@ -26,6 +26,8 @@ class VSCodeWorkspaceMarkdownDocumentProvider extends Disposable implements Work
private _watcher: vscode.FileSystemWatcher | undefined;
private readonly utf8Decoder = new TextDecoder('utf-8');
async getAllMarkdownDocuments() {
const resources = await vscode.workspace.findFiles('**/*.md', '**/node_modules/**');
const docs = await Promise.all(resources.map(doc => this.getMarkdownDocument(doc)));
@ -88,7 +90,7 @@ class VSCodeWorkspaceMarkdownDocumentProvider extends Disposable implements Work
const bytes = await vscode.workspace.fs.readFile(resource);
// We assume that markdown is in UTF-8
const text = Buffer.from(bytes).toString('utf-8');
const text = this.utf8Decoder.decode(bytes);
const lines: SkinnyTextLine[] = [];
const parts = text.split(/(\r?\n)/);