fix(lsp): do not expand $VAR in tagfunc filenames #41398

Problem:
CTRL-] via lsp tagfunc passes URI paths through :tag, which expands
\$VAR, so files like people_.\$personId.tsx fail with E429.

Solution:
fnameescape() the filename in tag items so \$ is treated as literal.
This commit is contained in:
Shubh
2026-08-23 21:00:17 +05:30
committed by GitHub
parent bca9c4afa7
commit c5cb0350a6
2 changed files with 20 additions and 1 deletions

View File

@@ -12,9 +12,10 @@ local function mk_tag_item(name, range, uri, position_encoding)
-- This is get_line_byte_from_position is 0-indexed, call cursor expects a 1-indexed position
local pos = vim.pos.lsp(bufnr, range.start, position_encoding)
local byte = pos.col + 1
-- :tag expands "$VAR" in filenames. Escape so URI paths keep literal "$". #41313
return {
name = name,
filename = vim.uri_to_fname(uri),
filename = vim.fn.fnameescape(vim.uri_to_fname(uri)),
cmd = string.format([[/\%%%dl\%%%dc/]], range.start.line + 1, byte),
}
end