diff options
author | Ilia Choly <ilia.choly@gmail.com> | 2024-02-28 04:50:53 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-28 10:50:53 +0100 |
commit | 0190771713241b10872b9e2118e16ea4e4b2d1a0 (patch) | |
tree | f299588493d835d262a7cd4ea8acc71e467045f7 /test/functional/lua | |
parent | cb146cc4aad746053535533cbea8834414ea82a2 (diff) | |
download | rneovim-0190771713241b10872b9e2118e16ea4e4b2d1a0.tar.gz rneovim-0190771713241b10872b9e2118e16ea4e4b2d1a0.tar.bz2 rneovim-0190771713241b10872b9e2118e16ea4e4b2d1a0.zip |
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.
Diffstat (limited to 'test/functional/lua')
-rw-r--r-- | test/functional/lua/uri_spec.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/functional/lua/uri_spec.lua b/test/functional/lua/uri_spec.lua index e238bc8a82..dacaf95867 100644 --- a/test/functional/lua/uri_spec.lua +++ b/test/functional/lua/uri_spec.lua @@ -88,6 +88,12 @@ describe('URI methods', function() eq('/xy/åäö/ɧ/汉语/↥/🤦/🦄/å/بِيَّ.txt', exec_lua(test_case)) end) + + it('file path with uri fragment', function() + exec_lua("uri = 'file:///Foo/Bar/Baz.txt#fragment'") + + eq('/Foo/Bar/Baz.txt', exec_lua('return vim.uri_to_fname(uri)')) + end) end) describe('decode Windows filepath', function() @@ -184,6 +190,15 @@ describe('URI methods', function() ]] ) end) + + it('uri_to_fname returns non-file schema URI with fragment unchanged', function() + eq( + 'scheme://path#fragment', + exec_lua [[ + return vim.uri_to_fname('scheme://path#fragment') + ]] + ) + end) end) end) |