From 977dc20bcbd9bd14293d1e40d88de014db01f451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Menu?= Date: Thu, 30 Sep 2021 09:03:37 +0200 Subject: [PATCH] Fix crash when creating a new note fails (#83) --- internal/cli/cmd/new.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/cli/cmd/new.go b/internal/cli/cmd/new.go index 0126474..0999e73 100644 --- a/internal/cli/cmd/new.go +++ b/internal/cli/cmd/new.go @@ -42,15 +42,17 @@ func (cmd *New) Run(container *cli.Container) error { Extra: cmd.Extra, Date: time.Now(), }) - path := filepath.Join(notebook.Path, note.Path) - if err != nil { + var path string + if err == nil { + path = filepath.Join(notebook.Path, note.Path) + } else { var noteExists core.ErrNoteExists if !errors.As(err, ¬eExists) { return err } if confirmed, _ := container.Terminal.Confirm( - fmt.Sprintf("%s already exists, do you want to edit this note instead?", note.Path), + fmt.Sprintf("%s already exists, do you want to edit this note instead?", noteExists.Name), true, ); !confirmed { // abort...