Skip to content

Commit

Permalink
Fix active parameter in signature help (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
gatesn authored Sep 25, 2017
1 parent f941b55 commit 2d502da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pyls/plugins/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ def pyls_signature_help(document, position):
'documentation': ""
} for p in s.params]

# We only return a single signature because Python doesn't allow overloading
sig_info = {'signatures': [sig], 'activeSignature': 0}

if s.index is not None and s.params:
# Then we know which parameter we're looking at
sig['activeParameter'] = s.index
sig_info['activeParameter'] = s.index

return sig_info
7 changes: 6 additions & 1 deletion test/plugins/test_signature.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2017 Palantir Technologies, Inc.
import pytest
from pyls import uris
from pyls.plugins.signature import pyls_signature_help
from pyls.workspace import Document
Expand Down Expand Up @@ -28,7 +29,11 @@ def test_signature():
sig_position = {'line': 6, 'character': 5}
doc = Document(DOC_URI, DOC)

sigs = pyls_signature_help(doc, sig_position)['signatures']
sig_info = pyls_signature_help(doc, sig_position)

sigs = sig_info['signatures']
assert len(sigs) == 1
assert sigs[0]['label'] == 'main(param1, param2)'
assert sigs[0]['parameters'][0]['label'] == 'param1'

assert sig_info['activeParameter'] == 0

0 comments on commit 2d502da

Please sign in to comment.