Skip to content

Commit 6a10a79

Browse files
authored
feat: use generate_note_filename for renaming notes (#345)
1 parent b695fa6 commit 6a10a79

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lua/telekasten.lua

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1610,7 +1610,20 @@ end
16101610
local function RenameNote()
16111611
local oldfile = Pinfo:new({ filepath = vim.fn.expand("%:p"), M.Cfg })
16121612

1613-
fileutils.prompt_title(M.Cfg.extension, oldfile.title, function(newname)
1613+
local oldtitle = oldfile.title
1614+
local curuuid = ""
1615+
local escapedsep = M.Cfg.uuid_sep:gsub("[%(%)%.%%%+%-%*%?%[%^%$%]]", "%%%1")
1616+
1617+
if M.Cfg.new_note_filename == "uuid-title" then
1618+
curuuid, oldtitle =
1619+
oldfile.title:match("^(.-)" .. escapedsep .. "(.+)$")
1620+
elseif M.Cfg.new_note_filename == "title-uuid" then
1621+
oldtitle, curuuid =
1622+
oldfile.title:match("^(.+)" .. escapedsep .. "(.-)$")
1623+
end
1624+
1625+
fileutils.prompt_title(M.Cfg.extension, oldtitle, function(newname)
1626+
newname = generate_note_filename(curuuid, newname)
16141627
local newpath = newname:match("(.*/)") or ""
16151628
newpath = M.Cfg.home .. "/" .. newpath
16161629

0 commit comments

Comments
 (0)