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

Merged preview extension #86

Merged
merged 5 commits into from
Sep 17, 2020
Merged

Merged preview extension #86

merged 5 commits into from
Sep 17, 2020

Conversation

thomaskoppelaar
Copy link
Contributor

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.

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 Show resolved Hide resolved
src/extension.ts Outdated
}
;
}

Copy link
Owner

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

src/extension.ts Outdated Show resolved Hide resolved
src/extension.ts Outdated Show resolved Hide resolved
src/extension.ts Outdated Show resolved Hide resolved
src/extension.ts Outdated Show resolved Hide resolved
src/extension.ts Outdated Show resolved Hide resolved
src/extension.ts Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@@ -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",
Copy link
Owner

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?

Copy link
Contributor Author

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.

@kortina kortina merged commit ae31993 into kortina:ak-files-for-wiki-link-ref-from-cache-sync Sep 17, 2020
@thomaskoppelaar thomaskoppelaar deleted the ak-files-for-wiki-link-ref-from-cache-sync branch September 21, 2020 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants