fix(util.root): resolve bufpath for terminal windows

Extract path from terminal window name such as `term:/~/.local/share/nvim/lazy/LazyVim/2062833:/usr/bin/zsh`. The path `~/.local/share/nvim/lazy/LazyVim/2062833` can locate the correct directory for the terminal windows.
This commit is contained in:
ian 2026-03-25 13:58:35 +08:00 committed by GitHub
parent 96f4f18d7d
commit 3f2c1c41e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -67,7 +67,9 @@ function M.detectors.pattern(buf, patterns)
end
function M.bufpath(buf)
return M.realpath(vim.api.nvim_buf_get_name(assert(buf)))
local path = LazyVim.norm(vim.api.nvim_buf_get_name(assert(buf)))
-- Use pattern to extract path for terminal windows
return M.realpath(path and path:match("^term:/([^:]+)") or path)
end
function M.cwd()