From a3c8d25299e4834ff7ec5ce46b8fdb4daf65e4e0 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Mon, 25 Sep 2023 14:08:57 +0200 Subject: [PATCH] added: change a setting in main command palette --- main.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/main.js b/main.js index 99279cd..d721937 100644 --- a/main.js +++ b/main.js @@ -939,18 +939,22 @@ function editsettings() }); } +function editsetting(name) +{ + if (settings[name]) + { + settings[name] = prompt(name, settings[name]); + savesettings(); + loadsettings(); + } +} + function changesetting() { searchinlist(Object.keys(settings).map(name => name + ": " + settings[name])) .then(setting => { - var name = setting.split(":").shift(); - if (settings[name]) - { - settings[name] = prompt(name, settings[name]); - savesettings(); - loadsettings(); - } + editsetting(setting.split(":").shift()); }); } @@ -1797,7 +1801,7 @@ function commandpalette() .map(c => c.hint) .concat(snippets.map(s => "Insert snippet: " + s.hint)) .concat(list().map(t => "Open note: " + t)) - ) + .concat(Object.keys(settings).map(s => "Edit setting: " + s))) .then(hint => { var command = commands.find(c => c.hint == hint); @@ -1817,6 +1821,10 @@ function commandpalette() { loadnote(hint.replace("Open note: ", "")); } + else if (hint.startsWith("Edit setting: ")) + { + editsetting(hint.replace("Edit setting: ", "")); + } else { // if unknown command, create a new note