From 997ad9c5ed063e2093321963d09089d233f1a5f6 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Mon, 6 Nov 2023 09:59:01 +0100 Subject: [PATCH] added: option to display note tags in command palette --- main.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/main.js b/main.js index 478752d..1dad1ee 100644 --- a/main.js +++ b/main.js @@ -17,7 +17,8 @@ var defaultsettings = colors: true, bulletrendering: "•", password: "", - sync: false + sync: false, + tagsinpalette: true }; //builtin @@ -997,7 +998,10 @@ function gettags(note) if (i > -1) { var j = note.content.indexOf("\n", i); - return note.content.substring(i + 6, j).split(",").map(t => t.toLowerCase().trim()); + return note.content.substring(i + 6, j) + .split(",") + .map(t => t.toLowerCase().trim()) + .filter(t => t.length); } return []; } @@ -1628,7 +1632,19 @@ function commandpalette() .filter(c => !c.excludepalette) .map(c => c.hint) .concat(snippets.map(s => "Insert snippet: " + s.hint)) - .concat(list().map(t => "Open note: " + t)) + .concat(localdata.map(n => + { + var entry = "Open note: " + n.title; + if (settings.tagsinpalette) + { + var tags = gettags(n); + if (tags.length) + { + entry += " - tags: " + tags.join(); + } + } + return entry; + })) .concat(Object.keys(settings).map(s => "Edit setting: " + s))) .then(hint => { @@ -1647,7 +1663,7 @@ function commandpalette() } else if (hint.startsWith("Open note: ")) { - loadnote(hint.replace("Open note: ", "")); + loadnote(hint.replace("Open note: ", "").replace(/ - tags:.*/, "")); } else if (hint.startsWith("Edit setting: ")) {