Ptvs: Autocomplete is inserting incorrect text when user presses shift + another key

Created on 7 Jan 2019  路  3Comments  路  Source: microsoft/PTVS

Due to autocomplete's numerous race conditions and performance problems (see https://github.com/Microsoft/PTVS/issues/4895), it often doesn't have correct suggestions.

Currently there is a behavior (I guess its default visual studio behavior) where whatever suggestion autocomplete has is inserted when the user presses shift+any key.

For instance, suppose I want to type variable.get_value(). Very often PTVS's realtime intellisense database will be incomplete because it is too slow, so the suggestion get_value won't generally be available in the autocomplete suggestion list until possibly 5-10 seconds after I type variable.

Then typing the characters v a r i a b l e . g e t _ v a l u e ( ) before the database is ready will generally autofill with whatever is at the top of the suggestion list starting with the letter g when it reaches the character (, resulting in variable.got_wrong_suggestion() for instance, even when got_wrong_suggestion is clearly not what the user requested. This occurs because the suggestion list is not pruned quickly enough while the user is typing, and by the time the user hits (, a nonsense suggestion remains in the list, and is incorrectly inserted.

Just to be clear, by the time a user types v a r i a b l e . g e...., autocomplete should know that it's not trying to type variable.got_wrong_suggestion(), and it shouldn't even be in the completion list at that point. The user typing that e character should _trigger_ the immediate removal of that suggestion and all others not matching the so-far typed characters. Every character typed should trigger this pruning routine, so that there are never any incorrect suggestions (like the other visual studio language modules).

The fact that this incorrect suggestion remains in the completion list, and this is incorrectly inserted, suggests there is a race condition between the code for automatically inserting suggestions and the code populating and removing suggestions. This is separate from the problem where getting the correct suggestion is too slow.

Given some effort into really controlling the numerous race conditions plaguing the auto-completion feature, auto-completion could be really nice, even with a slow database. Right now, it is unusable, and has been for a long time. At least add a way of disabling autocomplete!

IntelliSense Legacy Language Support bug

Most helpful comment

Thanks for the feedback @joseortiz3 (and for the other comments on the other bugs, which I've read).

To help with your immediate issue, I would suggest that you go to tools/options/text editor/python/advanced page, and clear the text box for "committed by typing the following characters". This will reduce the IntelliSense "aggressiveness", it will only complete if you press TAB.

I agree with you that IntelliSense has been subpar for years. The analysis engine would be able to give you better results than competitors, but was brought down by performance, reliability issues, and the IntelliSense client code sometimes ruins perfectly good results or gets in the way when the results are not ready, like you are describing.

The analysis engine server part has been split off into its own project (https://github.com/Microsoft/python-language-server) for Visual Studio Code 6 months ago, and the work involved in making that happen has been destabilizing for VS. The good news is that now there's a team working on the language server, and they are making good progress on performance and reliability. Resource availability is such that the many bug fixes that went in the LSP haven't made it back into Visual Studio yet. Integration is being worked on at the moment, and at best/earliest it will be in VS 2019 Preview 3.

As far as the "client" side, I am hopeful that we'll be able to prioritize it after the server re-integration is done. Feedback like yours is important to help convince managers this is what should be worked on.

There are 2 possible improvements that I would like to investigate, not sure yet which one we'll go for yet:

  • Switch to the language server protocol (LSP) client (https://github.com/Microsoft/PTVS/issues/4740)
  • Switch over to the new VS async completion APIs introduced in 15.8 (don't have the bug handy)

The LSP client would have the big advantage of providing a standard set of editor functionality for free for us, so a big win a terms of maintenance. It's a big investment just to try it out though. We do a lot of custom stuff, like inspecting live objects for completions in REPL. LSP client is supposed to be flexible enough for us to hook into it, but you never know.

The VS async completion API is not as big of a change, and we would still have to own the implementation of several editor features, but along with some cleanup that would be required to use it, may give a sufficiently improved IntelliSense experience.

All 3 comments

Thanks for the feedback @joseortiz3 (and for the other comments on the other bugs, which I've read).

To help with your immediate issue, I would suggest that you go to tools/options/text editor/python/advanced page, and clear the text box for "committed by typing the following characters". This will reduce the IntelliSense "aggressiveness", it will only complete if you press TAB.

I agree with you that IntelliSense has been subpar for years. The analysis engine would be able to give you better results than competitors, but was brought down by performance, reliability issues, and the IntelliSense client code sometimes ruins perfectly good results or gets in the way when the results are not ready, like you are describing.

The analysis engine server part has been split off into its own project (https://github.com/Microsoft/python-language-server) for Visual Studio Code 6 months ago, and the work involved in making that happen has been destabilizing for VS. The good news is that now there's a team working on the language server, and they are making good progress on performance and reliability. Resource availability is such that the many bug fixes that went in the LSP haven't made it back into Visual Studio yet. Integration is being worked on at the moment, and at best/earliest it will be in VS 2019 Preview 3.

As far as the "client" side, I am hopeful that we'll be able to prioritize it after the server re-integration is done. Feedback like yours is important to help convince managers this is what should be worked on.

There are 2 possible improvements that I would like to investigate, not sure yet which one we'll go for yet:

  • Switch to the language server protocol (LSP) client (https://github.com/Microsoft/PTVS/issues/4740)
  • Switch over to the new VS async completion APIs introduced in 15.8 (don't have the bug handy)

The LSP client would have the big advantage of providing a standard set of editor functionality for free for us, so a big win a terms of maintenance. It's a big investment just to try it out though. We do a lot of custom stuff, like inspecting live objects for completions in REPL. LSP client is supposed to be flexible enough for us to hook into it, but you never know.

The VS async completion API is not as big of a change, and we would still have to own the implementation of several editor features, but along with some cleanup that would be required to use it, may give a sufficiently improved IntelliSense experience.

To help with your immediate issue, I would suggest that you go to tools/options/text editor/python/advanced page, and clear the text box for "committed by typing the following characters". This will reduce the IntelliSense "aggressiveness", it will only complete if you press TAB.

Yessss so much better now. Users: I highly recommend using this setting until PTVS gets a language server upgrade. Thanks again.

I used IntelliSense in VS for C++ and for Python. Python one is waaay behind C++ one.

Hope that more effort can be put on that because it will help a lot for Python VS adoption.

Regards

Was this page helpful?
0 / 5 - 0 ratings