mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 14:14:24 -05:00
fix: issue with special char in new filename (closes #178)
This commit is contained in:
@@ -168,6 +168,11 @@ local function defaultConfig(home)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- escapes a string for use as exact pattern within gsub
|
||||||
|
local function escape(s)
|
||||||
|
return string.gsub(s, "[%%%]%^%-$().[*+?]", "%%%1")
|
||||||
|
end
|
||||||
|
|
||||||
local function file_exists(fname)
|
local function file_exists(fname)
|
||||||
if fname == nil then
|
if fname == nil then
|
||||||
return false
|
return false
|
||||||
@@ -207,7 +212,7 @@ local function generate_note_filename(uuid, title)
|
|||||||
local pp = Path:new(title)
|
local pp = Path:new(title)
|
||||||
local p_splits = pp:_split()
|
local p_splits = pp:_split()
|
||||||
local filename = p_splits[#p_splits]
|
local filename = p_splits[#p_splits]
|
||||||
local subdir = title:gsub(filename, "")
|
local subdir = title:gsub(escape(filename), "")
|
||||||
|
|
||||||
local sep = M.Cfg.uuid_sep or "-"
|
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" and #title > 0 then
|
||||||
@@ -275,11 +280,6 @@ local function global_dir_check()
|
|||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
--- escapes a string for use as exact pattern within gsub
|
|
||||||
local function escape(s)
|
|
||||||
return string.gsub(s, "[%%%]%^%-$().[*+?]", "%%%1")
|
|
||||||
end
|
|
||||||
|
|
||||||
local function make_config_path_absolute(path)
|
local function make_config_path_absolute(path)
|
||||||
local ret = path
|
local ret = path
|
||||||
if not (Path:new(path):is_absolute()) and path ~= nil then
|
if not (Path:new(path):is_absolute()) and path ~= nil then
|
||||||
|
|||||||
Reference in New Issue
Block a user