From 231a9da8f3d88f9cb5dfaaddd4585600eac3a1a8 Mon Sep 17 00:00:00 2001 From: Beau McCartney Date: Sat, 9 Sep 2023 12:51:50 -0600 Subject: [PATCH] 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. --- lua/genghis.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/genghis.lua b/lua/genghis.lua index 5fe8dae..62cf397 100644 --- a/lua/genghis.lua +++ b/lua/genghis.lua @@ -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