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

Add option to always show word based suggestions #21611

Open
OliverJAsh opened this issue Mar 1, 2017 · 28 comments
Open

Add option to always show word based suggestions #21611

OliverJAsh opened this issue Mar 1, 2017 · 28 comments
Assignees
Labels
feature-request Request for new features or functionality suggest IntelliSense, Auto Complete
Milestone

Comments

@OliverJAsh
Copy link
Contributor

  • 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.

@mjbvz mjbvz added bug Issue identified by VS Code Team member as probable bug typescript Typescript support issues and removed bug Issue identified by VS Code Team member as probable bug labels Mar 1, 2017
@mjbvz
Copy link
Collaborator

mjbvz commented Mar 8, 2017

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

@OliverJAsh
Copy link
Contributor Author

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?

@jrieken
Copy link
Member

jrieken commented Mar 8, 2017

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...

@rubencaro
Copy link

rubencaro commented Apr 2, 2017

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: timmhirsens/vscode-elixir#56

@jrieken
Copy link
Member

jrieken commented Apr 3, 2017

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

It would result in many duplicates

@justnonamenoname
Copy link

justnonamenoname commented Apr 7, 2017

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 Code\resources\app\out\vs\workbench\electron-browser\workbench.main.js

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

@jrieken jrieken added the under-discussion Issue is under discussion for relevance, priority, approach label Apr 21, 2017
@zabel-xyz
Copy link

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?

@swhitlow
Copy link

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.

@mjbvz mjbvz changed the title Word based suggestions not working in TypeScript Add option to always show word based suggestions Dec 21, 2017
@tboby
Copy link

tboby commented Feb 25, 2018

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.

@jrieken
Copy link
Member

jrieken commented Feb 26, 2018

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

@pupa91
Copy link

pupa91 commented Nov 30, 2020

我想我找到了解决方案。此扩展程序具有此功能。

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

Thanks for your answers.

@WilliamVenner
Copy link

It should be possible to specify when returning in provideCompletionItems that you would like to show the user word-based completions mixed with custom completions, but you should also be able to specify which type of completions are sorted above the other, e.g. word based > custom, or custom > word based.

@pbaksa
Copy link

pbaksa commented Apr 27, 2021

It would be great if an extension could get the default word-based suggestion list and filter/modify it.

@FUJonathan
Copy link

FUJonathan commented May 26, 2021

I would also greatly appreciate if this could be implemented somehow. I haven't looked at the code, but wouldn't it be possible to either filter out duplicates in the suggestion list before presenting it to the user or not add a new entry if it's already in the list?

I find myself wanting to autocomplete function and variable names from the code I'm working on more often than those in the language itself, but I still want to use language extensions for syntax highlighting, etc., so I would even be happy with an option to toggle an extension's autocomplete off altogether and just use word suggestions.

@linonetwo
Copy link

TabNine can also provide alphabet result ( it can provide strings based on what you have in your workspace), but it also suffered from this bug:

codota/tabnine-vscode#525

I think the reason behind this issue and that bug is the same, somehow extensions registered provider be overwritten by some other extension's registered provider.

SO this is a bug in VSCode.

@Zenthae

This comment has been minimized.

@tjx666
Copy link
Contributor

tjx666 commented Mar 10, 2022

If this issue be fixed,js project completion experience will be improved greatly.

@W4RH4WK
Copy link
Contributor

W4RH4WK commented May 15, 2022

This issue is not exclusive to js/ts, right?

I do have the same issue with the C++ auto-completion. Sometimes semantic auto-completion takes quite a bit of time in larger C++ code-bases. Most of the time, I'd be happy with just word-based completion. However, like this issue points out, they don't seem to be merged into the same suggestion list.

@linonetwo

This comment was marked as spam.

@dyodji
Copy link

dyodji commented Jul 7, 2022

Changing my registration from monaco.languages.registerCompletionItemProvider("MyScriptNameHere", ... to monaco.languages.registerCompletionItemProvider("*",... allowed me to see mixed word-based and custom suggestions for the DSL I'm creating an editor for.
image

That said, I agree that it would be nicer if this were configurable as suggested by others here. At the very least you should be able to assign a list of token types to be made available to suggest (e.g. my specific issue was that we lost suggestion of variable names when registering a CompletionItemProvider more specific than '*' which opened us up to too many 'fat finger' mistakes.)

@pbaksa
Copy link

pbaksa commented Jul 8, 2022

Thanks, after all I can do my own document filtering.

@jli
Copy link

jli commented Nov 26, 2022

My usecase for always wanting word-based completion: when writing code, I'll reference functions that don't exist, but which I am going to define later. When I do this, I need to type the function name twice, or copy and paste it. It would be great if I could auto-complete it!

def some_complex_function(x):
    tmp = some_utility_function(x)
    # ...other stuff...

def some_ut # it would be cool if this would autocomplete to `some_utility_function`

@haskelcurry

This comment was marked as spam.

@haskelcurry

This comment was marked as spam.

@alainpannetier
Copy link

Any updates on this?

Don't wait. Folks are still in VisualBasic IDE mode.
Here is an extension that does the job.
https://marketplace.visualstudio.com/items?itemName=RahulSinha.hippie-completion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality suggest IntelliSense, Auto Complete
Projects
None yet
Development

No branches or pull requests