Skip to content

Commit

Permalink
Remove slash and star from positional snippets (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
andfoy authored Mar 18, 2020
1 parent e20bf30 commit 21833ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions pyls/plugins/jedi_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,16 @@ def _format_completion(d, include_params=True):

if (include_params and hasattr(d, 'params') and d.params and
not is_exception_class(d.name)):
positional_args = [param for param in d.params if '=' not in param.description]
positional_args = [param for param in d.params
if '=' not in param.description and
param.name not in {'/', '*'}]

if len(positional_args) > 1:
# For completions with params, we can generate a snippet instead
completion['insertTextFormat'] = lsp.InsertTextFormat.Snippet
snippet = d.name + '('
for i, param in enumerate(positional_args):
name = param.name if param.name != '/' else '\\/'
snippet += '${%s:%s}' % (i + 1, name)
snippet += '${%s:%s}' % (i + 1, param.name)
if i < len(positional_args) - 1:
snippet += ', '
snippet += ')$0'
Expand Down
2 changes: 1 addition & 1 deletion test/plugins/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def test_snippet_parsing(config):
'completion': {'completionItem': {'snippetSupport': True}}}
config.update({'plugins': {'jedi_completion': {'include_params': True}}})
completions = pyls_jedi_completions(config, doc, completion_position)
out = 'logical_and(${1:x1}, ${2:x2}, ${3:\\/}, ${4:*})$0'
out = 'logical_and(${1:x1}, ${2:x2})$0'
assert completions[0]['insertText'] == out


Expand Down

0 comments on commit 21833ea

Please sign in to comment.