Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change reading file from native fs to vscode alternative #1295

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pderaaij
Copy link
Collaborator

This PR changes the lasst occurence of reading files natively from fs. This is required for using Foam on the web version of vscode, but also follows best practices.

@pderaaij pderaaij added the foam-core Related to API, core model or feature label Oct 11, 2023
Copy link
Collaborator

@riccardoferretti riccardoferretti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pulling out this change, I believe it's great to have the code itself ready for the transition, so that the rest is just a matter of build and testing.

I have a question about the approach though, see my comment in the diff.

let noteText = readFileSync(note.uri.toFsPath()).toString();
let noteText;

vsWorkspace.fs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this will work?
I am not sure this would work, as this call returns a promise, and whether noteText is actually set when needed (e.g. line 192) becomes a matter of timing.
This is the reason why originally we didn't migrate this part of the code from readFileSync.

Am I missing something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not working. Need to refine it, but needed a test run on thr CI as I had some issues locally. Forgot to add wip to the PR ;)

@pderaaij
Copy link
Collaborator Author

I am not sure how we can get this working. markdown-it is synchronous by design. On that same note, vascode is asynchronous intentional. Two things that doesn't work well together. I am not sure how to continue. The only hunch I have is to change its implementation from a regex replace to a custom renderer. But that would require quite some research.

Any ideas moving forward are welcome. This is a blocking issue to get Foam working properly on the web (#749).

@riccardoferretti
Copy link
Collaborator

Yup, that limitation of markdown-it is quite something. Here are some thoughts I had about working around it, let me know what you think: #1116 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
foam-core Related to API, core model or feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants