From 76498666500c2aee94fd07366222d76c4d13ee2f Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Sat, 21 Jan 2023 18:02:51 -0800 Subject: [PATCH] fix: shortened path for current directory is '.' --- lua/oil/fs.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/oil/fs.lua b/lua/oil/fs.lua index 774b0a0..3a5efa1 100644 --- a/lua/oil/fs.lua +++ b/lua/oil/fs.lua @@ -73,7 +73,11 @@ local home_dir = vim.loop.os_homedir() M.shorten_path = function(path) local cwd = vim.fn.getcwd() if vim.startswith(path, cwd) then - return path:sub(cwd:len() + 2) + local relative = path:sub(cwd:len() + 2) + if relative == "" then + relative = "." + end + return relative end if vim.startswith(path, home_dir) then return "~" .. path:sub(home_dir:len() + 1)