fix(lua): remove uri fragment from file paths (#27647)

Problem: Some LSP servers return `textDocument/documentLink` responses
         containing file URIs with line/column numbers in the fragment.
         `vim.uri_to_fname` returns invalid file names for these URIs.

Solution: Remove the URI fragment from file URIs.
This commit is contained in:
Ilia Choly
2024-02-28 04:50:53 -05:00
committed by GitHub
parent cb146cc4aa
commit 0190771713
2 changed files with 19 additions and 0 deletions

View File

@@ -104,6 +104,10 @@ function M.uri_to_fname(uri)
if scheme ~= 'file' then
return uri
end
local fragment_index = uri:find('#')
if fragment_index ~= nil then
uri = uri:sub(1, fragment_index - 1)
end
uri = M.uri_decode(uri)
--TODO improve this.
if is_windows_file_uri(uri) then