From f74619b662fb24f79f79318a36a282516e19b63e Mon Sep 17 00:00:00 2001 From: madmaxieee <76544194+madmaxieee@users.noreply.github.com> Date: Wed, 3 Jun 2026 00:33:44 +0800 Subject: [PATCH] fix(picker.util): require trailing slash when matching git root in truncpath When `git.get_root` returns "." (e.g. inside a git repo with a relative path), the old `path:find(root, 1, true)` would match the leading dot of dotfiles like ".stylua.toml", replacing it with the root tail and producing "./tylua.toml". By matching `root .. "/"` instead of bare `root`, we ensure the root is only matched as a directory prefix, so dotfiles and other paths starting with "." are left intact. --- lua/snacks/picker/util/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/snacks/picker/util/init.lua b/lua/snacks/picker/util/init.lua index 81e4e1f62..c7fb73afa 100644 --- a/lua/snacks/picker/util/init.lua +++ b/lua/snacks/picker/util/init.lua @@ -29,7 +29,7 @@ function M.truncpath(path, len, opts) path = path:sub(#cwd + 2) else local root = Snacks.git.get_root(path) - if root and root ~= "" and path:find(root, 1, true) == 1 then + if root and root ~= "" and path:find(root .. "/", 1, true) == 1 then local tail = vim.fn.fnamemodify(root, ":t") path = "⋮" .. tail .. "/" .. path:sub(#root + 2) elseif path:find(home, 1, true) == 1 then