fix(lsp): callHierarchy/outgoingCalls ranges are relative to caller, not callee #39336

Problem:
The fromRanges field of the result of callHierarchy/outgoingCalls is
documented as being relative to the caller. Using
vim.lsp.buf.outgoing_calls() opened the qflist with an entry with the
callee's filename, but the caller's line number.

Solution:
Open the qflist with the callers file (the bufnr from the request),
rather than the callees (the uri from the resulting CallHierarchyItem)
This commit is contained in:
Ashley Hauck
2026-04-23 14:20:58 +02:00
committed by GitHub
parent ecb8402197
commit 7e006b06c4
2 changed files with 14 additions and 4 deletions

View File

@@ -106,13 +106,14 @@ describe('vim.lsp.buf', function()
},
}
local handler = require 'vim.lsp.handlers'['callHierarchy/outgoingCalls']
handler(nil, rust_analyzer_response, {})
local bufnr = vim.api.nvim_get_current_buf()
handler(nil, rust_analyzer_response, { bufnr = bufnr })
return vim.fn.getqflist()
end)
local expected = {
{
bufnr = 2,
bufnr = 1,
col = 5,
end_col = 0,
lnum = 4,