fix(followlink): create link with subdirs on the fly

This commit is contained in:
Thomas Lambert
2023-02-11 22:44:04 +01:00
parent 1069d67b9b
commit 6290e52f97

View File

@@ -272,7 +272,7 @@ local function check_dir_and_ask(dir, purpose)
.. " Shall I create it? ", .. " Shall I create it? ",
}, function(answer) }, function(answer)
if answer == "Yes" then if answer == "Yes" then
if Path:new(dir):mkdir({ exists_ok = false }) then if Path:new(dir):mkdir({ parents=true, exists_ok = false }) then
vim.cmd('echomsg " "') vim.cmd('echomsg " "')
vim.cmd('echomsg "' .. dir .. ' created"') vim.cmd('echomsg "' .. dir .. ' created"')
ret = true ret = true
@@ -2257,6 +2257,12 @@ local function FollowLink(opts)
end end
if search_mode == "files" then if search_mode == "files" then
-- check if subdir exists
local filepath = title:match("(.*/)") or ""
filepath = M.Cfg.home .. "/" .. filepath
check_dir_and_ask(filepath, "")
-- check if fname exists anywhere -- check if fname exists anywhere
local pinfo = Pinfo:new({ title = title }) local pinfo = Pinfo:new({ title = title })
if if