From c1fb7c06319c6c1a5d66f0a1865fdece6cce0def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Pupier?= Date: Fri, 25 Nov 2022 15:27:02 +0100 Subject: [PATCH] Use VS Code FS API instead of Node fs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit it will allow to compliant with VS Code web part of #648 Signed-off-by: Aurélien Pupier --- src/providers/xref.provider.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/providers/xref.provider.ts b/src/providers/xref.provider.ts index 6ebbda91..c4243568 100644 --- a/src/providers/xref.provider.ts +++ b/src/providers/xref.provider.ts @@ -1,4 +1,3 @@ -import { readFileSync } from 'fs' import * as vscode from 'vscode' import { createContext, Context } from './createContext' @@ -31,9 +30,11 @@ function shouldProvide (context: Context): boolean { async function getLabels (): Promise { const files = await vscode.workspace.findFiles('**/*.adoc') - const contentOfFilesConcatenated = files - .map((uri) => readFileSync(uri.path).toString('utf-8')) - .join('\n') + let contentOfFilesConcatenated = '' + for (const uri of files) { + const data = await vscode.workspace.fs.readFile(uri) + contentOfFilesConcatenated += Buffer.from(data).toString('utf8') + '\n' + } const labelsFromLegacyBlock = await getLabelsFromLegacyBlock(contentOfFilesConcatenated) const labelsFromShorthandNotation = await getLabelsFromShorthandNotation(contentOfFilesConcatenated) const labelsFromLonghandNotation = await getLabelsFromLonghandNotation(contentOfFilesConcatenated)