Description
- 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 (
:
- Filter the completion list by the
(
- Remove the
(
from the completion text to be inserted, and adjust the range accordingly - 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.