Skip to content

Commit

Permalink
Handle label in a signature help when it is a list
Browse files Browse the repository at this point in the history
  • Loading branch information
yegappan committed Feb 8, 2024
1 parent fa7c75c commit 5cab3be
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions autoload/lsp/signature.vim
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,36 @@ export def SignatureHelp(lspserver: dict<any>, sighelp: any): void
var hllen: number = 0
var startcol: number = 0
if sig->has_key('parameters') && sighelp->has_key('activeParameter')
var params_len = sig.parameters->len()
if params_len > 0 && sighelp.activeParameter < params_len
var label: string = sig.parameters[sighelp.activeParameter].label
hllen = label->len()
startcol = text->stridx(label)
var params: list<dict<any>> = sig.parameters
var params_len: number = params->len()
var activeParam: number = sighelp.activeParameter
if params_len > 0 && activeParam < params_len
var paramInfo: dict<any> = params[activeParam]
var label: any = paramInfo.label
if label->type() == v:t_string
# label string
var label_str: string = label
hllen = label_str->len()
startcol = text->stridx(label_str)
else
# [inclusive start offset, exclusive end offset]
var label_offset: list<number> = params[activeParam].label
var start_offset: number = label_offset[0]
var end_offset: number = label_offset[1]

if has('patch-9.0.1629')
# Convert UTF-16 offsets
startcol = text->byteidx(start_offset, true)
var endcol: number = text->byteidx(end_offset, true)
hllen = endcol - startcol
else
startcol = start_offset
hllen = end_offset - start_offset
endif
endif
endif
endif

if opt.lspOptions.echoSignature
:echon "\r\r"
:echon ''
Expand Down

0 comments on commit 5cab3be

Please sign in to comment.