mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07:00
feat(lsp.util): simplify some bounds checking
This commit is contained in:
parent
0621718e3b
commit
d44d36b8ff
@ -843,16 +843,12 @@ function M.convert_signature_help_to_markdown_lines(signature_help, ft, triggers
|
|||||||
if signature.parameters and #signature.parameters > 0 then
|
if signature.parameters and #signature.parameters > 0 then
|
||||||
-- First check if the signature has an activeParameter. If it doesn't check if the response
|
-- First check if the signature has an activeParameter. If it doesn't check if the response
|
||||||
-- had that property instead. Else just default to 0.
|
-- had that property instead. Else just default to 0.
|
||||||
local active_parameter = (signature.activeParameter or signature_help.activeParameter or 0)
|
local active_parameter =
|
||||||
if active_parameter < 0 then
|
math.max(signature.activeParameter or signature_help.activeParameter or 0, 0)
|
||||||
active_parameter = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
-- If the activeParameter is > #parameters, then set it to the last
|
-- If the activeParameter is > #parameters, then set it to the last
|
||||||
-- NOTE: this is not fully according to the spec, but a client-side interpretation
|
-- NOTE: this is not fully according to the spec, but a client-side interpretation
|
||||||
if active_parameter >= #signature.parameters then
|
active_parameter = math.min(active_parameter, #signature.parameters - 1)
|
||||||
active_parameter = #signature.parameters - 1
|
|
||||||
end
|
|
||||||
|
|
||||||
local parameter = signature.parameters[active_parameter + 1]
|
local parameter = signature.parameters[active_parameter + 1]
|
||||||
local parameter_label = parameter.label
|
local parameter_label = parameter.label
|
||||||
|
Loading…
Reference in New Issue
Block a user