Vscode: Add option to always show word based suggestions

Created on 1 Mar 2017  路  13Comments  路  Source: microsoft/vscode

  • VSCode Version: 1.9.1

Steps to Reproduce:

  1. Go to an empty TypeScript file
  2. Enter fooBarBaz
  3. Enter a new line and then type fooBa

Expected result: word based quick suggestions should show.

Actual result: no quick suggestions. Ctrl+space shows a popup with content 'No suggestions'.

image

Try the same in a JavaScript file and it works.

I would like IntelliSense and word based suggestions for my TypeScript.

feature-request suggest

Most helpful comment

I suggest to add option for allow word-based with compiler provider
no words is more big problem then if you have duplicates

words

it's possible to enable this at this moment only to modify
Microsoft VS Coderesourcesappoutvsworkbenchelectron-browserworkbench.main.js

find
if(!h)return a.TPromise.join(r.map(function(r)
change to
return a.TPromise.join(r.map(function(r)

All 13 comments

After looking into this, I don't think JavaScript has word based suggestions in your example either. The result you see in the js case is actually a suggestion entry returned by TypeScript, not one provided by VSCode's word based suggestions.

The root cause: the word based suggestion completion item provider is less specific than the JS and TS completion item providers. Our suggest logic only looks at the most specific completion provider that return a valid result: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/suggest/common/suggest.ts#L66

This suggest logic is not specific to JavaScript or TypeScript and I can trigger the same sort of behavior in languages like python as well.

@jrieken and @alexandrudima: Is the lack of word based suggestions when a more specific suggestion provided returns results the designed behavior? I could see word based suggestions cluttering up the list in most cases where a language suggestion provider exists, but wanted to confirm that the current behavior is as-designed

Interesting, thanks for investigating. In my case the most specific provider returns no results, so in this case at least it should fallback to the word based provider?

Is the lack of word based suggestions when a more specific suggestion provided returns results the designed behavior?

Yes, but this is a good sample of it going wrong. The idea is that each provider gets a score based on its language selector, in short a full selector like typescript get 10 points whereas the * selector gets only 5 points. Then we start with those providers that have the highest score, ask them, and unless they produce a result, continue with the next bucket. We do this to prevent mixing good suggestions with word based suggestions.

This works well for cases like word-based suggestions in comments or when typing the name of a declaration because TS usually doesn't return anything then. The problem with the sample above is that TypeScript returns many suggestions after fooBa and that our logic doesn't do the filtering yet (matching each suggestion with the text it wants to replace). Because we now have suggestions from a smart provider, we don't ask the word-based provider anymore.

Not yet sure what to do here...

Because we now have suggestions from a smart provider, we don't ask the word-based provider anymore.

Why don't you keep asking the word-based provider to complete the list of suggestions? The 'smart' provider is not always so smart, and word-based suggestions are enough most of the time. In this case there would still be some word-based suggestions even if the smart provider does not give any.

Just the same way you always add the snippets provider: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/suggest/common/suggest.ts#L52

This seems to affect every suggestion provider, not only TS/JS: fr1zle/vscode-elixir#56

Why don't you keep asking the word-based provider to complete the list of suggestions?

It would result in many duplicates

I suggest to add option for allow word-based with compiler provider
no words is more big problem then if you have duplicates

words

it's possible to enable this at this moment only to modify
Microsoft VS Coderesourcesappoutvsworkbenchelectron-browserworkbench.main.js

find
if(!h)return a.TPromise.join(r.map(function(r)
change to
return a.TPromise.join(r.map(function(r)

I have the same problem in my extension plsql.
I added some special snippets and all the suggestions of words were lost.
So I added a filter to return only the completion items starting with the current word.
How can I improve this?

Just wanted to comment to say that justnonamenoname's solution worked for me. I was able to make that change to the core code and it is now working perfectly for PHP files, etc.

I am now trying to figure out how to make this adjustment permanently until it gets fixed in the core base.

As an extension writer I would very much like to be able to fallback to word based suggestions.

It is going to take me a long time to be able to provide full smart completion, so it would be nice to be able to supplement the word based completion, not replace it.

I would very much like to be able to fallback to word based suggestions.

You can do that, simply return undefined, null, or an empty result set and it will fallback to word based suggestions

In addition to enabling both IntelliSense and word-based suggestions, there must be an option to enable _only_ word-based suggestions, for those cases where IntelliSense isn't Intelli enough.

In other words, the settings should be two independent Booleans:

  1. Enable intelligent suggestions.
  2. Enable word-based suggestions.

I think I found the solution to this. This extension does this feature.

https://marketplace.visualstudio.com/items?itemName=Atishay-Jain.All-Autocomplete

I found a solution to my problem which only occurred when editing Python code: uninstall the Python plugin. You will still get syntax highlighting, but the autocompletion will show the words and only the words that are in the file, just like ctrl+P in Vim. The suggestions also show up immediately, rather than after a delay. :tada:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mariusa picture mariusa  路  219Comments

hsdk123 picture hsdk123  路  263Comments

TurkeyMan picture TurkeyMan  路  411Comments

Tyriar picture Tyriar  路  200Comments

stoffeastrom picture stoffeastrom  路  380Comments