text-snippets-obsidian icon indicating copy to clipboard operation
text-snippets-obsidian copied to clipboard

Multiline snippets in folders

Open TinyAtoms opened this issue 2 years ago • 4 comments

Here is a working proof of concept of what I wanted and how multiline snippets could be implemented. It is not in a state where it should be merged yet. No error handling to speak of, no tests, etc. I do want to know what you think of this method of implementation, and suggestions on how you would do it. My alternative method was going to be using something like using something like

file : TAbstractFile = this.app.metadataCache.getFirstLinkpathDest(this,settings.multilineFolder +selectedText, "");
newstr = this.app.vault.cachedRead(file).then((content) => this.mlSnippets[file.basename] = content);
if (newStr == null) newstr = ""

in findSnippet. My reasoning for not doing it that way is that it might produce noticable delays after trying to insert.

TinyAtoms avatar May 10 '22 21:05 TinyAtoms

My reasoning for not doing it that way is that it might produce noticable delays after trying to insert.

Can multiline snippets be loaded to snippets variable in settings, so delays will be less?

ArianaKhit avatar May 12 '22 09:05 ArianaKhit

You could, but then you'd lose the simplicity of that, and would be doing something like what I'm doing in the PR. The simplicity in directly reading it from the file is that you don't have to monitor the multiline snippet folder. As soon as you move it in memory, you'd have to make sure that your in-memory copy reflects that folder, so you'd have to monitor it.

TinyAtoms avatar May 12 '22 14:05 TinyAtoms

Then I think this method will be just fine, you can use one of the latest versions of the code, without errors while loading the plugin in Live Preview, if you want to test it

ArianaKhit avatar May 12 '22 14:05 ArianaKhit

Is there progress on this issue? I'm very much looking forward to use this feature. :)

willow512 avatar Jun 09 '22 08:06 willow512