Skip to content

Automatic insertion of parens doesn't interact nicely with completions, results in duplicated characters #26012

Closed
microsoft/azuredatastudio
#7206
@DanTup

Description

@DanTup
  • VSCode Version: 1.11.2
  • OS Version: Windows 10

Assume the following code (cursor is where the | is):

foo() {
}


main() {
  fo|
}

Completion is returning foo(). If the user continues to type o( then the o 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:

main() {
  foo()) // <-- two closing parens
}

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 (:

  1. Filter the completion list by the (
  2. Remove the ( from the completion text to be inserted, and adjust the range accordingly
  3. Because a character was auto-inserted after the cursor, subtract that character from the end of the insertion text (and adjust the range) if it's the same character

I think 1 & 2 already happen, I think 3 would make sense to fix this.

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugsuggestIntelliSense, Auto CompleteverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions