added: change a setting in main command palette

This commit is contained in:
quenousimporte 2023-09-25 14:08:57 +02:00
parent 2935034202
commit a3c8d25299
1 changed files with 16 additions and 8 deletions

20
main.js
View File

@ -939,18 +939,22 @@ function editsettings()
});
}
function changesetting()
function editsetting(name)
{
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();
}
}
function changesetting()
{
searchinlist(Object.keys(settings).map(name => name + ": " + settings[name]))
.then(setting =>
{
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