fix definition jump error

pull/296/head
CnsMaple 6 months ago
parent 29d5f05bf9
commit e42012d757

@ -37,17 +37,18 @@ local definition_hdlr = function(err, locations, ctx, _)
local items = locations_to_items(locations) local items = locations_to_items(locations)
gui.new_list_view({ items = items, api = 'Definition', title = 'Definition' }) gui.new_list_view({ items = items, api = 'Definition', title = 'Definition' })
else else
local loc = vim.lsp.util.make_position_params() vim.lsp.util.jump_to_location(locations[1], oe)
-- let check if the location is same as current -- local loc = vim.lsp.util.make_position_params()
if -- -- let check if the location is same as current
loc.textDocument.uri == locations[1].uri -- if
and loc.position.line == locations[1].range.start.line -- loc.textDocument.uri == locations[1].uri
and loc.position.character == locations[1].range.start.character -- and loc.position.line == locations[1].range.start.line
then -- and loc.position.character == locations[1].range.start.character
vim.lsp.buf.type_definition() -- then
else -- vim.lsp.buf.type_definition()
vim.lsp.util.jump_to_location(locations[1], oe) -- else
end -- vim.lsp.util.jump_to_location(locations[1], oe)
-- end
end end
else else
vim.lsp.util.jump_to_location(locations, oe) vim.lsp.util.jump_to_location(locations, oe)

Loading…
Cancel
Save