Skip to content

Commit b0491b1

Browse files
committed
fix(lsp): roslyn LSP non-standard URIs (#2218)
1 parent 3e644b8 commit b0491b1

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

lua/fzf-lua/actions.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ M.vimcmd_entry = function(_vimcmd, selected, opts, pcall_vimcmd)
154154
entry.line = lnum or entry.line
155155
-- "<none>" could be set by `autocmds`
156156
if entry.path == "<none>" then return end
157-
local fullpath = entry.bufname or entry.uri and entry.uri:match("^%a+://(.*)") or entry.path
157+
local fullpath = entry.bufname
158+
or entry.uri and entry.uri:match("^[%a%-]+://(.*)")
159+
or entry.path
158160
-- Something is not right, goto next entry
159161
if not fullpath then return end
160162
if not path.is_absolute(fullpath) then

lua/fzf-lua/path.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,14 @@ function M.entry_to_location(entry, opts)
411411
}
412412
end
413413

414+
---Test for URI, note this include non-standard URIs, some LSPs like dotnet's
415+
---roslyn prepend entries with "roslyn-source-generated://" (#2218)
416+
---@param str string
417+
---@return boolean
418+
function M.is_uri(str)
419+
return str:match("^[%a%-]+://") ~= nil
420+
end
421+
414422
---@param entry string
415423
---@param opts fzf-lua.Config?
416424
---@param force_uri boolean?
@@ -432,7 +440,7 @@ function M.entry_to_file(entry, opts, force_uri)
432440
-- Convert "~" to "$HOME"
433441
stripped = M.tilde_to_HOME(stripped)
434442
-- Prepend cwd unless entry is already a URI (e.g. nvim-jdtls "jdt://...")
435-
local isURI = stripped:match("^%a+://")
443+
local isURI = M.is_uri(stripped)
436444
local cwd = opts.cwd or opts._cwd
437445
if cwd and #cwd > 0 and not isURI and not M.is_absolute(stripped) then
438446
stripped = M.join({ cwd, stripped })
@@ -494,7 +502,7 @@ function M.entry_to_file(entry, opts, force_uri)
494502
file, line = stripped:match("([^:]+):(%d+)")
495503
end
496504
end
497-
if opts.path_shorten and not stripped:match("^%a+://") then
505+
if opts.path_shorten and not M.is_uri(stripped) then
498506
file = M.lengthen(file)
499507
end
500508
return {

lua/fzf-lua/providers/buffers.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ local function gen_buffer_entry(opts, buf, max_bufnr, cwd, prefix)
140140
local rightbr = "]"
141141
local bufname = (function()
142142
local bname = buf.info.name
143-
if bname:match("^%[.*%]$") or bname:match("^%a+://") then
143+
if bname:match("^%[.*%]$") or path.is_uri(bname) then
144144
return bname
145145
elseif opts.filename_only then
146146
return path.tail(bname)

0 commit comments

Comments
 (0)