From 0b77827fdb0160a78b218035ee67d86bf91e1483 Mon Sep 17 00:00:00 2001 From: bhagwan Date: Mon, 15 Jan 2024 00:57:03 -0500 Subject: [PATCH] fix(paths): `HOME_to_tilde` case insensitive on windows --- lua/fzf-lua/path.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lua/fzf-lua/path.lua b/lua/fzf-lua/path.lua index 3e8a3b88..ef3247af 100644 --- a/lua/fzf-lua/path.lua +++ b/lua/fzf-lua/path.lua @@ -249,7 +249,16 @@ end ---@param path string? ---@return string? function M.HOME_to_tilde(path) - return path and path:gsub("^" .. utils.lua_regex_escape(M.HOME()), "~") or nil + if not path then return end + if utils.__IS_WINDOWS then + local home = M.HOME() + if path:sub(1, #home):lower() == home:lower() then + path = "~" .. path:sub(#home + 1) + end + else + path = path:gsub("^" .. utils.lua_regex_escape(M.HOME()), "~") + end + return path end local function find_next_separator(str, start_idx)