aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2023-10-03 17:51:39 +0800
committercrupest <crupest@outlook.com>2023-10-03 17:51:39 +0800
commitd2f58ecc1c796abc901fde7fcf2ccd4f73fa08ea (patch)
tree4432a997938d49de05a4922dfde8a8cb2d3a1688
parent025540a8ca302fceb3d8d0c024c0895fb24eb2aa (diff)
downloadcrupest-d2f58ecc1c796abc901fde7fcf2ccd4f73fa08ea.tar.gz
crupest-d2f58ecc1c796abc901fde7fcf2ccd4f73fa08ea.tar.bz2
crupest-d2f58ecc1c796abc901fde7fcf2ccd4f73fa08ea.zip
Fix a critical walkup bug in nvim config.
-rw-r--r--configs/nvim/lua/crupest/system/fs.lua13
1 files changed, 7 insertions, 6 deletions
diff --git a/configs/nvim/lua/crupest/system/fs.lua b/configs/nvim/lua/crupest/system/fs.lua
index c879239..2f489c3 100644
--- a/configs/nvim/lua/crupest/system/fs.lua
+++ b/configs/nvim/lua/crupest/system/fs.lua
@@ -1,21 +1,22 @@
local function clean_path(path)
- return path and (string.gsub(path, "[/\\]+", "/"))
-end
-
-local function full_path(name)
- local path = vim.fn.fnamemodify(name, ":p:gs?\\?/?")
+ path = string.gsub(path, "[/\\]+", "/")
if string.sub(path, string.len(path)) == '/' then
path = string.sub(path, 1, string.len(path) - 1)
end
return path
end
+local function full_path(name)
+ local path = vim.fn.fnamemodify(name, ":p")
+ return clean_path(path)
+end
+
local function escape_space(str)
return (string.gsub(str, " ", "\\ "))
end
local function path_get_dir(path)
- return vim.fn.fnamemodify(full_path(path), ":h")
+ return full_path(vim.fn.fnamemodify(clean_path(path), ":h"))
end
local function walk_up(path, func)