fix: correctly parse the directory of a given path to a file

The previous `gsub` call would blow away everything after and including
the first '/' in the pathname, including other slashes.

Fortunately, the neovim api provides a way to get the parent directory
of a given path, which I've used instead.
remotes/origin/HEAD
Beau McCartney 2023-09-09 12:51:50 -06:00
parent b46b5c33cb
commit 231a9da8f3
1 changed files with 1 additions and 1 deletions

View File

@ -96,7 +96,7 @@ local function fileOp(op)
-- DETERMINE PATH AND EXTENSION
local hasPath = newName:find("/")
if hasPath then
local newFolder = newName:gsub("/.-$", "")
local newFolder = vim.fs.dirname(newName)
fn.mkdir(newFolder, "p") -- create folders if necessary
end