fix(treesitter): :InspectTree wrong title for non-relative path #37965

Problem:  :InspectTree sets wrong title for file with non-relative path.
Solution: Use full path if relpath() returns nil.
This commit is contained in:
zeertzjq
2026-02-20 01:05:48 +08:00
committed by GitHub
parent 9567fb0507
commit 08f4811061
2 changed files with 32 additions and 1 deletions

View File

@@ -378,7 +378,7 @@ function M.inspect_tree(opts)
local opts_title = opts.title
if not opts_title then
local bufname = api.nvim_buf_get_name(buf)
title = ('Syntax tree for %s'):format(vim.fs.relpath('.', bufname))
title = ('Syntax tree for %s'):format(vim.fs.relpath('.', bufname) or bufname)
elseif type(opts_title) == 'function' then
title = opts_title(buf)
end