From 08cb518c25e9a65834e647f895a446b59de2d739 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sun, 28 Jan 2018 18:19:56 +0000 Subject: [PATCH] Check if current folder exists --- .travis.yml | 2 +- CliClient/app/autocompletion.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 54ae6c7b82..8cc841f6f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/CliClient/app/autocompletion.js b/CliClient/app/autocompletion.js index c11227030c..ade05f5c13 100644 --- a/CliClient/app/autocompletion.js +++ b/CliClient/app/autocompletion.js @@ -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)); }