Skip to content
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

"editor.suggestSelection": "recentlyUsed" frozen? #77254

Closed
jabacchetta opened this issue Jul 11, 2019 · 8 comments
Closed

"editor.suggestSelection": "recentlyUsed" frozen? #77254

jabacchetta opened this issue Jul 11, 2019 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug javascript JavaScript support issues *out-of-scope Posted issue is not in scope of VS Code suggest IntelliSense, Auto Complete typescript Typescript support issues
Milestone

Comments

@jabacchetta
Copy link

jabacchetta commented Jul 11, 2019

  • VSCode Version: 1.36.1
  • OS Version: macOS Mojave 10.14.4
  • Does this issue occur when all extensions are disabled?: Yes

In certain files of a project, I'm apparently getting a recently used completion that I can't reset (I've tried all the clear commands).

But more importantly than being able to reset it, it seems like "recently used" could be improved on to take into account more factors (e.g. context and how recently).

See the screenshot below, where a word suggestion continues to be selected regardless of how many times I autocomplete something else (i.e. slice).

example

@jrieken jrieken added info-needed Issue requires more information from poster suggest IntelliSense, Auto Complete labels Jul 12, 2019
@jrieken
Copy link
Member

jrieken commented Jul 12, 2019

Please provide repro steps

@jabacchetta
Copy link
Author

OK, took me some experimenting to figure out how to reproduce this, but think I figured it out.

  1. Add the following settings:
{
  // // TODO: See if TypeScript has the same issue
  // "typescript.suggest.completeFunctionCalls": true,

  // `completeFunctionCalls` appears to be the problematic setting
  "javascript.suggest.completeFunctionCalls": true
}
  1. Create a JavaScript file with the following code:
const num = 1;
const str = 'foo';
  1. Type str.n and then accept/autocomplete the word based, num suggestion.

  2. Type str.sl and accept the slice suggestion.

  3. Type in str. and notice that num is still being prioritized as the most recent autocompletion (when slice should be prioritized at this point).

  4. Remove the completeFunctionCalls setting given above.

  5. Repeat steps 3-5 above. But this time, notice that the slice suggestion is properly being prioritized.

@vscodebot vscodebot bot removed the new release label Jul 14, 2019
@jrieken jrieken removed the info-needed Issue requires more information from poster label Jul 23, 2019
@jrieken jrieken assigned mjbvz and unassigned jrieken Jul 23, 2019
@jrieken
Copy link
Member

jrieken commented Jul 23, 2019

This is an issue with TypeScript as it seems that the insertText differs, sometimes it's just .slice and sometimes it's .slice($1)$0. The LRU suggest memory selects recent item based on language, completion type, and insert text and if that differs an item isn't selected.

Screenshot 2019-07-23 at 17 28 56

@mjbvz
Copy link
Collaborator

mjbvz commented Aug 15, 2019

@jrieken Thanks for the investigation. Here's more detail on why this is happening:

  1. In provideCompletionItems, we always return basic completion items with insert text such as .slice.
  2. We only create the snippet based completions (such as .slice($1)$0) when the compeletion item is resolved
  3. After accepting a completion, the suggestion memory stores the resolved completion item. When the next completion request comes in, it then tries matching the stored resolved completion item against unresolved completion items. This fails for .slice($1)$0

Do you think this is something we could fix in VS Code itself? Any potential workarounds? We can't eagerly resolve the insert text for JS/TS as that can be an expensive operation

@mjbvz mjbvz added javascript JavaScript support issues typescript Typescript support issues bug Issue identified by VS Code Team member as probable bug labels Aug 15, 2019
@jrieken
Copy link
Member

jrieken commented Aug 15, 2019

We only create the snippet based completions (such as .slice($1)$0) when the compeletion item is resolved

⬆️ That is the issue, actually the cause of multiple issues. The resolve-call should never change the insert behaviour of a completion. It was a mistake not to enforce that because it's the root of much evil.

We can't eagerly resolve the insert text for JS/TS as that can be an expensive operation

I honestly think we must do that. With #73311 we already realised that items must be resolved asap and that we cannot wait once we show them. The only fix on our side I see is to forcefully call resolve before showing items - defeating the purpose of resolve...

@mjbvz
Copy link
Collaborator

mjbvz commented Aug 15, 2019

Ok, I will look to see what the cost of creating the insert text eagerly and if it is even possible to do with the existing TS api

@mjbvz mjbvz added this to the August 2019 milestone Aug 15, 2019
@mjbvz
Copy link
Collaborator

mjbvz commented Aug 16, 2019

Ok, I investigated this and found we cannot fix this on the JS/TS side without dropping support for completeFunctionCalls.

The reason is that completeFunctionCalls generates the insert text using the displayText that typescript returns when resolving completion items. Doing this eagerly for all completion items would be expensive.

This request against TS may be relevant: microsoft/TypeScript#25207

Moving to backlog since I don't know how to fix it this iteration

@mjbvz mjbvz modified the milestones: August 2019, Backlog Aug 16, 2019
@mjbvz
Copy link
Collaborator

mjbvz commented Oct 15, 2020

Closing this due to lack of further user feedback over the past year.

Long term, I feel that we should move completeFunctionCalls to TypeScript with microsoft/TypeScript#25207

@mjbvz mjbvz closed this as completed Oct 15, 2020
@mjbvz mjbvz added the *out-of-scope Posted issue is not in scope of VS Code label Oct 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug javascript JavaScript support issues *out-of-scope Posted issue is not in scope of VS Code suggest IntelliSense, Auto Complete typescript Typescript support issues
Projects
None yet
Development

No branches or pull requests

3 participants