-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatic insertion of parens doesn't interact nicely with completions, results in duplicated characters #26012
Comments
@alexandrudima Is there a way I can halt electric brackets for a moment? |
@jrieken I'm not 100% sure what you mean. The code for handling typing is at The cursor goes into that if the Would you want in the |
ping @jrieken What do you want in terms of editor API here ? |
There is another issue about the same thing: redhat-developer/vscode-java#503. Since VS Code has taken over completion at this point, there is no chance for language server to handle with such case. VS Code should correct the bracket according to the current content and the snippet given by the language server. |
This is related to #10266 but the automatic brackets force you into this situation... |
Pulling a Python example from #70786. The root cause there was that snippets and auto closing pairs don't play nice together. Snippet: {
"listcompPy": {
"prefix":"[x for x in",
"body":[
"[x for x in range(1,20) if x%2==0 ]"
]
}
} typing [x for x in range(1,20) if x%2==0 ]] |
@jrieken glad to see this fixed in that commit! What is your recommendation for how the above python snippet should look? As it does there or something different? |
Thank you @jrieken for the fix. I tried in the Insider version it works like a charm! |
The Python example listed above does not work still. |
It depends. Trigger IntelliSense, type |
Assume the following code (cursor is where the
|
is):Completion is returning
foo()
. If the user continues to typeo(
then theo
and(
are "subtracted" from the completion client-side by Code (it doesn't send another request to the completion provider). This works great; however since typing the(
auto-inserts a)
if the user then uses the completion, they will end up with:There's an animation showing a slightly different version or this at Dart-Code/Dart-Code#285
I can't see how the completion provider can fix this, since Code has taken over completion at this point (it's filtering and reducing the completion text client-side). I think the best thing would be for Code to subtract any auto-inserted characters from the end of the completion text in the same way it's removing the typed characters from the start.
Eg, when the user types the
(
:(
(
from the completion text to be inserted, and adjust the range accordinglyI think 1 & 2 already happen, I think 3 would make sense to fix this.
The text was updated successfully, but these errors were encountered: