From f3d5309f440eff1243531fcaf938454d45b4f42f Mon Sep 17 00:00:00 2001 From: Spencer Gouw Date: Thu, 22 Jun 2023 05:26:15 -0700 Subject: [PATCH] feat: added newline as snippet divider --- main.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/main.ts b/main.ts index 6d53c38..423b5ef 100644 --- a/main.ts +++ b/main.ts @@ -142,13 +142,18 @@ export default class JellySnippets extends Plugin { } parseSearchSnippets(): void { + // If they specified newline control character, split snippets by newline + let snippetDivider = + this.settings.snippetDivider == "\\n" + ? "\n" + : this.settings.snippetDivider; + // go through the search snippets file, split by the snippet divider, split by the part divider, put in map - let snippetLines = this.settings.searchSnippetsFile.split( - this.settings.snippetDivider - ); + let snippetLines = + this.settings.searchSnippetsFile.split(snippetDivider); for (let snippet of snippetLines) { // trim() is used so that each snippet line does not retain newlines. - // TODO: Add the newline symbol for dividers. + // TODO: Again, control characters or semantic symbols in lhs. let snippetParts = snippet .trim() .split(this.settings.snippetPartDivider); @@ -335,7 +340,7 @@ class JellySnippetsSettingTab extends PluginSettingTab { new Setting(childEl) .setName("Snippet line divider") .setDesc( - "This string will divide each separate snippet definition." + "This string will divide each separate snippet definition. (Enter the two characters '\\n' to use newlines as your separator.)" ) .addText((text) => text