Skip to content

Commit 41168c3

Browse files
committed
Replace direct use of fs by vscode.workspace
1 parent 4b28317 commit 41168c3

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

packages/foam-vscode/src/features/preview/wikilink-embed.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*global markdownit:readonly*/
22

33
// eslint-disable-next-line no-restricted-imports
4-
import { readFileSync } from 'fs';
54
import { workspace as vsWorkspace } from 'vscode';
65
import markdownItRegex from 'markdown-it-regex';
76
import { isSome, isNone } from '../../utils';
@@ -177,7 +176,7 @@ function fullExtractor(
177176
parser: ResourceParser,
178177
workspace: FoamWorkspace
179178
): string {
180-
let noteText = readFileSync(note.uri.toFsPath()).toString();
179+
let noteText = vsWorkspace.fs.readFile(toVsCodeUri(note.uri)).toString();
181180
const section = Resource.findSection(note, note.uri.fragment);
182181
if (isSome(section)) {
183182
const rows = noteText.split('\n');
@@ -194,7 +193,7 @@ function contentExtractor(
194193
parser: ResourceParser,
195194
workspace: FoamWorkspace
196195
): string {
197-
let noteText = readFileSync(note.uri.toFsPath()).toString();
196+
let noteText = vsWorkspace.fs.readFile(toVsCodeUri(note.uri)).toString();
198197
let section = Resource.findSection(note, note.uri.fragment);
199198
if (!note.uri.fragment) {
200199
// if there's no fragment(section), the wikilink is linking to the entire note,

0 commit comments

Comments
 (0)