Skip to content

Commit

Permalink
Use VS Code FS API instead of Node fs
Browse files Browse the repository at this point in the history
it will allow to compliant with VS Code web

part of asciidoctor#648

Signed-off-by: Aurélien Pupier <[email protected]>
  • Loading branch information
apupier committed Nov 25, 2022
1 parent 0fea3ca commit f117268
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/providers/xref.provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { readFileSync } from 'fs'
import * as vscode from 'vscode'
import { createContext, Context } from './createContext'

Expand Down Expand Up @@ -31,9 +30,11 @@ function shouldProvide (context: Context): boolean {

async function getLabels (): Promise<string[]> {
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)
Expand Down

0 comments on commit f117268

Please sign in to comment.