Skip to content

Commit

Permalink
feat: use generate_note_filename for renaming notes (#345)
Browse files Browse the repository at this point in the history
  • Loading branch information
onemoresuza authored Oct 26, 2024
1 parent b695fa6 commit 6a10a79
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lua/telekasten.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,20 @@ end
local function RenameNote()
local oldfile = Pinfo:new({ filepath = vim.fn.expand("%:p"), M.Cfg })

fileutils.prompt_title(M.Cfg.extension, oldfile.title, function(newname)
local oldtitle = oldfile.title
local curuuid = ""
local escapedsep = M.Cfg.uuid_sep:gsub("[%(%)%.%%%+%-%*%?%[%^%$%]]", "%%%1")

if M.Cfg.new_note_filename == "uuid-title" then
curuuid, oldtitle =
oldfile.title:match("^(.-)" .. escapedsep .. "(.+)$")
elseif M.Cfg.new_note_filename == "title-uuid" then
oldtitle, curuuid =
oldfile.title:match("^(.+)" .. escapedsep .. "(.-)$")
end

fileutils.prompt_title(M.Cfg.extension, oldtitle, function(newname)
newname = generate_note_filename(curuuid, newname)
local newpath = newname:match("(.*/)") or ""
newpath = M.Cfg.home .. "/" .. newpath

Expand Down

0 comments on commit 6a10a79

Please sign in to comment.