1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-27 08:21:03 +02:00

Check if current folder exists

This commit is contained in:
Laurent Cozic 2018-01-28 18:19:56 +00:00
parent 6d04eab200
commit 08cb518c25
2 changed files with 6 additions and 4 deletions

View File

@ -1,5 +1,5 @@
# Only build tags (Doesn't work - doesn't build anything)
# if: tag IS present
if: tag IS present
rvm: 2.3.3

View File

@ -72,8 +72,10 @@ async function handleAutocompletionPromise(line) {
let argName = cmdUsage[positionalArgs - 1];
argName = cliUtils.parseCommandArg(argName).name;
if (argName == 'note' || argName == 'note-pattern' && app().currentFolder()) {
const notes = await Note.previews(app().currentFolder().id, { titlePattern: next + '*' });
const currentFolder = app().currentFolder();
if (argName == 'note' || argName == 'note-pattern') {
const notes = currentFolder ? await Note.previews(currentFolder.id, { titlePattern: next + '*' }) : [];
l.push(...notes.map((n) => n.title));
}
@ -83,7 +85,7 @@ async function handleAutocompletionPromise(line) {
}
if (argName == 'item') {
const notes = await Note.previews(app().currentFolder().id, { titlePattern: next + '*' });
const notes = currentFolder ? await Note.previews(currentFolder.id, { titlePattern: next + '*' }) : [];
const folders = await Folder.search({ titlePattern: next + '*' });
l.push(...notes.map((n) => n.title), folders.map((n) => n.title));
}