From 054247b9c1799edd5874231973db621553062a43 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Mon, 16 Oct 2023 08:19:29 -0700 Subject: [PATCH] fix: path shortening does proper subpath detection --- lua/oil/fs.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/oil/fs.lua b/lua/oil/fs.lua index e813e70..9fd5a1f 100644 --- a/lua/oil/fs.lua +++ b/lua/oil/fs.lua @@ -116,14 +116,14 @@ local home_dir = assert(uv.os_homedir()) ---@return string M.shorten_path = function(path) local cwd = vim.fn.getcwd() - if vim.startswith(path, cwd) then + if M.is_subpath(cwd, path) then local relative = path:sub(cwd:len() + 2) if relative == "" then relative = "." end return relative end - if vim.startswith(path, home_dir) then + if M.is_subpath(home_dir, path) then return "~" .. path:sub(home_dir:len() + 1) end return path