question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Completions unexpectedly add parentheses

See original GitHub issue

Copied from https://github.com/microsoft/vscode-python/issues/15858.

Environment data

  • VS Code version: 1.55.0
  • Extension version (available under the Extensions sidebar): 2021.3.680753044
  • OS and version: Ubuntu 20.04 LTS
  • Python version: 3.7, deadsnakes
  • Type of virtual environment used: virtualenv
  • Value of the python.languageServer setting: JediLSP

Expected behaviour

class Thing: pass

Th<tab> # should complete to:
Thing|     # cursor after completed word

Actual behaviour

class Thing: pass

Th<tab> # should complete to:
Thing(|)  # cursor between completed parens

As far as I can tell this is specific to the JediLSP integration – changing my language server to Jedi results in the expected completion.

It looks like this may also vary by Python version – in another codebase I’m working on (in a Python 3.5 virtualenv) I don’t get this behaviour.

I can maybe see why this is maybe useful if you’re planning to construct an instance or calling a function, though there are many other places where callable symbols are used in which you don’t want this to happen – passing them as callbacks and type annotations for example.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
GalaxySnailcommented, Oct 24, 2021

In case you’re interested in tweaking anything, here’s where snippet logic is implemented in this codebase: https://github.com/pappasam/jedi-language-server/blob/main/jedi_language_server/jedi_utils.py#L284

I think it’s https://github.com/pappasam/jedi-language-server/blob/1d30a5ae7fd441880a9f3343911f1bfef370bd40/jedi_language_server/jedi_utils.py#L284 (the get_snippet_signature function).

If the line number is necessary, it will be better to reference a commit hash (or a tag) than a branch.

1reaction
pappasamcommented, Apr 20, 2021

@PeterJCLaw since this is now being tracked elsewhere, I’m going to close this issue here. Please let me know if you disagree!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add parenthesis after auto-completing methods #1184 - GitHub
If I've a class A with doSomething() method defined on it and I do this - A a; a.doSo it pops up doSomething...
Read more >
Git can't add file - Stack Overflow
Assuming you've escape the parentheses, you're now passing two files to git add , one called "Default" and one called "(OSX).sublime-keymap" ...
Read more >
Auto-complete adds parentheses at the wrong place.
Auto-complete adds parentheses at the wrong place. ... Place the cursor under the commented line and retype the commented above line exactly as...
Read more >
Automatically close parenthesis when we open it - MathWorks
At the current time, the only automatic completion offered, i.e., closing of parens, is at the command line, in the simple fashion shown...
Read more >
Cannot disable auto-insert pair brackets – Rider Support
Have you tried to disable completion in "File | Settings | Editor | General | Code Completion" -> "Automatically insert parentheses after ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found