From e31630a8c4925df2dcf9c63ea3795921679daa21 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 30 Apr 2021 15:26:32 +0200 Subject: [PATCH] Fix function formatting getting zettel from dir --- .gitignore | 1 + README.md | 1 + lua/zettelkasten/list.lua | 11 ++++++----- lua/zettelkasten/list_spec.lua | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..364fdec --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +public/ diff --git a/README.md b/README.md index 31eef6b..a244116 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ next up: * [ ] zettel 'lens' (preview first headline + content of linked zettel through floating window etc, on keypress) * [ ] support *both* md-style and wiki-style links at the same time * [ ] file/directory exception list for gathering files, which will be ignored +* [ ] 'strict' mode *only* matching and following valid anchor links ## TODO: maintenance diff --git a/lua/zettelkasten/list.lua b/lua/zettelkasten/list.lua index c8c7ec6..ebbb78a 100644 --- a/lua/zettelkasten/list.lua +++ b/lua/zettelkasten/list.lua @@ -64,12 +64,13 @@ end -- Take a list of zettel as an optional variable, without which -- it will use the (recursive) results of the zettel_root directory. function ls.get_zettel(anchor, all) - local zettels = all or - ls.get_anchors_and_paths( - ls.get_all_files(o.zettel().rootdir, true)) - if not zettels then return end + if not all then + local files = ls.get_all_files(o.zettel().rootdir, true) + all = ls.get_anchors_and_paths(files) + end + if not all then return end - return zettels[anchor] + return all[anchor] end return ls diff --git a/lua/zettelkasten/list_spec.lua b/lua/zettelkasten/list_spec.lua index a132d77..cd02dfc 100644 --- a/lua/zettelkasten/list_spec.lua +++ b/lua/zettelkasten/list_spec.lua @@ -167,4 +167,5 @@ describe("get_zettel", function() ls.get_zettel(expected) assert.stub(fc).was_called_with(expected, true) end) + end)