-
Notifications
You must be signed in to change notification settings - Fork 65
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
Merged preview extension #86
Merged preview extension #86
Conversation
I've created a very simple way of caching (aka: just storing the result whenever we call the function) the notefiles. This gets used by the renderer in order to either: 1. Use the (first) found link from the cache 2. Create a new (relative) link from the given wikilink. This is all very cruddy and could definitely use improvement, but it works.
src/extension.ts
Outdated
} | ||
; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inside activate, I think we will need to do implement the following:
vscode.workspace.onDidCreateFiles((e: vscode.FileCreateEvent) => {
// 1. implement this func
// 2. insure document property of e exists
for f in e.files: ReadonlyArray<Uri> ...
NoteWorkspace.addFileToCache(f);
});
vscode.workspace.onDidDeleteFiles((e: vscode.FileCreateEvent) => {
// 1. implement this func
// 2. check the types of FileDeleteEvent properties
for f in e.files: ReadonlyArray<Uri> ...
NoteWorkspace.removeFileFromCache(f);
});
vscode.workspace.onDidRenameFiles((e: vscode.FileCreateEvent) => {
// 1. implement this func
// 2. insure document property of e exists
files: ReadonlyArray<{newUri: Uri, oldUri: Uri}>
NoteWorkspace.addFileToCache(f.newUri);
NoteWorkspace.removeFileFromCache(f.oldUri);
});
See: https://code.visualstudio.com/api/references/vscode-api for how these apis work.
Also, please double check for other events we might need to look into.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, About the caching: It's quite terrible right now, with me just saving the results from noteFiles()
everytime it gets called. I'll be quite honest - I've got no idea what I'm doing when it comes to this particular part of the code, so it might be better if you take a look at this yourself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As in: create a proper cache, rather than the current "just save it to an object every time" implementation.
@@ -187,6 +203,7 @@ | |||
"unified": "^9.0.0", | |||
"unist-util-find": "^1.0.1", | |||
"unist-util-visit": "^2.0.2", | |||
"@thomaskoppelaar/markdown-it-wikilinks": "1.3.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a separate repo, or should some of this code be moved in as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it's best to keep this separate - We can override practically all settings / functions from within require('@thomaskoppelaar/markdown-it-wikilinks')({})
, and people may want to use this themselves for exporting / rendering for their own personal use cases.
- Used NoteWorkspace methods rather than c.get to allow stubbing
I've created a very simple way of caching (aka: just storing the result whenever we call the function) the notefiles.
This gets used by the renderer in order to either:
This is all very cruddy and could definitely use improvement, but it works.