Skip to content

Commit

Permalink
fix(marks): preserve uri filenames with path_expand (#3029)
Browse files Browse the repository at this point in the history
  • Loading branch information
gzbfgjf2 authored Apr 5, 2024
1 parent 4626aaa commit d26b666
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lua/telescope/builtin/__internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ internal.marks = function(opts)
line = line,
lnum = lnum,
col = col,
filename = vim.fs.normalize(v.file or bufname),
filename = utils.path_expand(v.file or bufname),
}
-- non alphanumeric marks goes to last
if mark:match "%w" then
Expand Down
4 changes: 4 additions & 0 deletions lua/telescope/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ utils.path_expand = function(path)
path = { path, { "string" } },
}

if utils.is_uri(path) then
return path
end

if path:match "^[%%#<]" then
path = vim.fn.expand(path)
end
Expand Down
20 changes: 20 additions & 0 deletions lua/tests/automated/utils_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,26 @@ describe("path_expand()", function()
local path_newline = [[/home/user/hello\nworld]]
eq(path_newline, utils.path_expand(path_newline))
end)
describe("early return for uri", function()
local uris = {
[[https://www.example.com/index.html]],
[[ftp://ftp.example.com/files/document.pdf]],
[[mailto:user@example.com]],
[[tel:+1234567890]],
[[file:///home/user/documents/report.docx]],
[[news:comp.lang.python]],
[[ldap://ldap.example.com:389/dc=example,dc=com]],
[[git://github.com/user/repo.git]],
[[steam://run/123456]],
[[magnet:?xt=urn:btih:6B4C3343E1C63A1BC36AEB8A3D1F52C4EDEEB096]],
}

for _, uri in ipairs(uris) do
it(uri, function()
eq(uri, utils.path_expand(uri))
end)
end
end)
end)

describe("is_uri", function()
Expand Down

0 comments on commit d26b666

Please sign in to comment.