From 232799accf5ba427ee32b4d73c186de738616be6 Mon Sep 17 00:00:00 2001 From: Thomas Lambert Date: Tue, 27 Sep 2022 20:49:49 +0200 Subject: [PATCH] fix: bug with uuid and subdir This ensures the UUID is placed before the _filename_ part and not before the _subdir_ part if the title of the new file is specified as `subdir/myfile` --- lua/telekasten.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/telekasten.lua b/lua/telekasten.lua index 293dbc9..afe233e 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -200,10 +200,15 @@ local function get_uuid(opts) end local function generate_note_filename(uuid, title) + local pp = Path:new(title) + local p_splits = pp:_split() + local filename = p_splits[#p_splits] + local subdir = title:gsub(filename, "") + local sep = M.Cfg.uuid_sep or "-" if M.Cfg.new_note_filename ~= "uuid" and #title > 0 then if M.Cfg.new_note_filename == "uuid-title" then - return uuid .. sep .. title + return subdir .. uuid .. sep .. filename elseif M.Cfg.new_note_filename == "title-uuid" then return title .. sep .. uuid else