Skip to content

Commit 93f8e48

Browse files
fix: ide diagnostics without URI schema (#163)
* fix: ide diagnostics without URI schema * mock method
1 parent b75cafc commit 93f8e48

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

lua/claudecode/tools/get_diagnostics.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ local function handler(params)
4747
diagnostics = vim.diagnostic.get(nil)
4848
else
4949
local uri = params.uri
50-
-- Strips the file:// scheme
51-
local filepath = vim.uri_to_fname(uri)
50+
local filepath = vim.startswith(uri, "file://") and vim.uri_to_fname(uri) or uri
5251

5352
-- Get buffer number for the specific file
5453
local bufnr = vim.fn.bufnr(filepath)

tests/unit/tools/get_diagnostics_spec.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ describe("Tool: get_diagnostics", function()
4848
-- Real vim.uri_to_fname throws an error for URIs without proper scheme
4949
error("URI must contain a scheme: " .. uri)
5050
end)
51+
_G.vim.startswith = function(str, prefix)
52+
return str:sub(1, #prefix) == prefix
53+
end
5154
end)
5255

5356
after_each(function()
@@ -58,6 +61,7 @@ describe("Tool: get_diagnostics", function()
5861
_G.vim.json.encode = nil
5962
_G.vim.fn.bufnr = nil
6063
_G.vim.uri_to_fname = nil
64+
_G.vim.startswith = nil
6165
-- Note: We don't nullify _G.vim.lsp or _G.vim.diagnostic entirely
6266
-- as they are checked for existence.
6367
end)

0 commit comments

Comments
 (0)