Remove extraneous return values from linking tools

Some extra bool values were previously returned in linkNote and the
zk.link LSP command. These values were vestigial placeholders from
the initial refactor, in case extra information was useful. It turns out
this was not the case.
pull/284/head
Patrick Anker 1 year ago
parent b357d5b06c
commit 048c8e44e1
No known key found for this signature in database
GPG Key ID: 66338E6C32588ED1

@ -38,7 +38,11 @@ func executeCommandLink(notebook *core.Notebook, documents *documentStore, conte
note, err := notebook.FindByHref(*opts.Path, false)
if err != nil || note == nil {
if err != nil {
return nil, err
}
if note == nil {
return nil, errors.New("Requested note to link to not found!")
}
@ -48,14 +52,13 @@ func executeCommandLink(notebook *core.Notebook, documents *documentStore, conte
title: opts.Title,
}
ok, err := linkNote(notebook, documents, context, info)
err = linkNote(notebook, documents, context, info)
if !ok {
if err != nil {
return nil, err
}
return map[string]interface{}{
"ok": true,
"path": filepath.Join(notebook.Path, note.Path),
}, nil
}

@ -67,20 +67,20 @@ type linkInfo struct {
title *string
}
func linkNote(notebook *core.Notebook, documents *documentStore, context *glsp.Context, info *linkInfo) (bool, error) {
func linkNote(notebook *core.Notebook, documents *documentStore, context *glsp.Context, info *linkInfo) error {
if info.location == nil {
return false, errors.New("'location' not provided")
return errors.New("'location' not provided")
}
// Get current document to edit
doc, ok := documents.Get(info.location.URI)
if !ok {
return false, fmt.Errorf("Cannot insert link in '%s'", info.location.URI)
return fmt.Errorf("Cannot insert link in '%s'", info.location.URI)
}
formatter, err := notebook.NewLinkFormatter()
if err != nil {
return false, err
return err
}
path := core.NotebookPath{
@ -98,12 +98,12 @@ func linkNote(notebook *core.Notebook, documents *documentStore, context *glsp.C
formatterContext, err := core.NewLinkFormatterContext(path, *title, info.note.Metadata)
if err != nil {
return false, err
return err
}
link, err := formatter(formatterContext)
if err != nil {
return false, err
return err
}
go context.Call(protocol.ServerWorkspaceApplyEdit, protocol.ApplyWorkspaceEditParams{
@ -114,5 +114,5 @@ func linkNote(notebook *core.Notebook, documents *documentStore, context *glsp.C
},
}, nil)
return true, nil
return nil
}

Loading…
Cancel
Save