Skip to content

Commit 21833ea

Browse files
authored
Remove slash and star from positional snippets (#763)
1 parent e20bf30 commit 21833ea

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pyls/plugins/jedi_completion.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,16 @@ def _format_completion(d, include_params=True):
140140

141141
if (include_params and hasattr(d, 'params') and d.params and
142142
not is_exception_class(d.name)):
143-
positional_args = [param for param in d.params if '=' not in param.description]
143+
positional_args = [param for param in d.params
144+
if '=' not in param.description and
145+
param.name not in {'/', '*'}]
144146

145147
if len(positional_args) > 1:
146148
# For completions with params, we can generate a snippet instead
147149
completion['insertTextFormat'] = lsp.InsertTextFormat.Snippet
148150
snippet = d.name + '('
149151
for i, param in enumerate(positional_args):
150-
name = param.name if param.name != '/' else '\\/'
151-
snippet += '${%s:%s}' % (i + 1, name)
152+
snippet += '${%s:%s}' % (i + 1, param.name)
152153
if i < len(positional_args) - 1:
153154
snippet += ', '
154155
snippet += ')$0'

test/plugins/test_completion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def test_snippet_parsing(config):
200200
'completion': {'completionItem': {'snippetSupport': True}}}
201201
config.update({'plugins': {'jedi_completion': {'include_params': True}}})
202202
completions = pyls_jedi_completions(config, doc, completion_position)
203-
out = 'logical_and(${1:x1}, ${2:x2}, ${3:\\/}, ${4:*})$0'
203+
out = 'logical_and(${1:x1}, ${2:x2})$0'
204204
assert completions[0]['insertText'] == out
205205

206206

0 commit comments

Comments
 (0)