-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
Autocomplete annoyingly tries to complete in comments. #9504
Comments
@JapanIsShinto I can't reproduce the behavior you describe in the current insider build 1.4.0 or the last stable 1.3.1. with or without the C++ extension installed. Completion proposals are inserted on |
I was convinced that it was completing words on space, but now I can't reproduce that either. I'll go back and try to figure out why I thought that was the case. But I can say this-- autocomplete often doesn't do what I want when editing comments. Take for example a struct Foo that has a member Bar. This I can reproduce: // update Foo. At the point I type the period, I am given possible completions. I then type return because it's the end of the line and autocomplete types this for me: // update Foo.bar And then I have to go back and fix it. As my comments are likely to reference symbols in my code, this happens more often than I like. I guess what would be ideal would be that autocomplete would have some minor syntax awareness so that when in comments, completions would by default be turned off. Looking at the key bindings, it looks like Ctrl-Space ("Trigger Suggest") can manually activate it if needed in comments. |
What's happening (for me at least) is that autocomplete is popping up at the end of a line. So (as in @JapanIsShinto's example) if you type "fun" and autocomplete pops up suggesting "function" and you press return to start a new line... and "function" is entered into the comment. This is /really/ annoying and happens with unbearable frequency. Please fix it. :-( Version info: Version 1.3.1 |
There are two setting to control this: |
I'm not sure what happens when I add a comment on a closed issue. Let's find out. Thanks for the two settings changes. I haven't tried them yet, but it sounds like it will work. The only comment I'd add is that I've never changed the settings, so these are defaults. Microsoft should probably consider changing these defaults, because I can't imagine the situation where the current behavior is something actually desired. |
So I can't use word based suggestions and accept-suggestion-on-enter in code just to fix this dodgy behaviour in comments? Doesn't seem like a fix to me. I want to hit enter to accept autocomplete suggestions and I'd like word based suggestions too please. Just not in comments... |
Totally agree with @oheard, this is a really odd behavior, no other editor works like vscode when writing comments, and I used a lot of them.. |
Just came here to add a "me too". VS Code is a wonderful editor, except for writing comments where it is just appalling. It's gotten to the point where if I'm writing more than a one-line comment block, I'll do it in another text editor and then copy that into VS Code, just to avoid all the hassle with autocomplete in comments. Really there needs to be a means of disabling autocomplete in comments, and this needs to be default behaviour. |
Old thread, but I would to also point out Code's annoying and related behavior of doing block completion in C/C++ comments. For example, if I type any word with an apostrophe in it ("can't", "it's") inside a comment, I get a second apostrophe that I have to delete. I had to set "editor.autoClosingBrackets" to false to get rid of this behavior, which is normally quite useful. There needs to be some awareness that comments aren't code. |
Not sure why this issue is closed, as it's ongoing in VS Code 1.9.1. And I would guess it affects any/most languages. I'm writing Typescript and frequently have to go back and fix my comments after VS Code decides to autocomplete them. Really infuriating. Yes, there's a fix above, but do I have to lose these features outside of comments where they're useful, just to get "standard" editor behavior in the comments? Issue should be re-opened as it needs fixing. |
Reopening this issue, we want to revisit this in March. |
We have now the needed details available that allow us to offer more fine grained control over this. The idea is that we add more config, like 'never complete with words', 'never complete with words in strings', 'never complete with words in comments' |
Proposal form #1657 (comment) // nowhere
"editor.wordBasedCompletion": false,
// everywhere
"editor.wordBasedCompletion": true,
// somewhere
"editor.wordBasedCompletion": {
"inStrings": true,
"inComment": false,
"inCode": true
} |
an alternative to #9504 (comment) could be to not use a object but a value set
or the use of different individual settings, like
The latter is a completely new system. Questionable if @aeschli @sandy081 masters of settings and json. preferences or suggestions? |
or (last proposal 🤞 )
|
@aeschli Maybe not |
As this has been closed, does this mean it will be available in the next nightly build ("Insiders release"), and I can finally switch off auto-complete in comments and strings? If so, thanks for the hard work! (If not, and this issue was just about the settings control for it, could you link to the issue I need to be following for the implementation? Thanks!) |
@DarrenCook psst, already today can add this to your |
Thanks - it works. Can I suggest the default be changed from
}, (or all (I thought that was what one of the above commits was about, but I think that only affects what happens if you specify I also had to do:
Because snippets still work in comments/strings. They were less noisy, but I personally never use them anyway, so that fix is good enough. |
9965a5d did make the default |
Snippets in strings and comments is good feedback. Idea is to allow snippets to tell in what scopes they wanna be active. |
I have extracted #9504 (comment) to #22661 |
Reopening this because this isn't just a problem with word-based (aka stupid) completions but with completions inside comments in general, esp or only when showing as you type (aka 24x7 IntelliSense, quick-suggestions). Instead (or in addition) to configuring word-based completions we should make the quick-suggest behaviour dependent on the scope (comment, string, other) |
Ok. I have reverted the "editor.quickSuggestions": {
"other": true,
"comments": false,
"strings": false
} This means suggestions (from any provider, including snippets) are still available in comments and strings, but only when explicitly requested either via Ctrl+Space or when typing a trigger-character but not in the 24x7 manner, not showing suggestions as you type. This should make it a lot less annoying and allows pressing enter in a comment without accidentally selecting a more or less random suggestion |
Are periods considered a trigger character? Because if they are then there's still an issue with hitting enter after ending a sentence in a comment. |
They are but only ask those providers that contributed them, mainly smart providers like TypeScript, C#, and they will not produce a result so it shouldn't be a problem |
@jrieken |
If you register yourself as a completion item provider on characters like |
An interesting find using:
In a Go file this works with single line comments; hitting '.' does not pop up the options box. However, in a multi-line comment the '.' still triggers the box. |
cc @ramya-rao-a for go completing in multiline comments. The setting is only about quick suggestions, not trigger characters. When invoked a completion item provider should always check if it makes sense to complete at that code location |
I'm new to Visual Studio Code, so be gentle. There is new behavior in VSCode (or at least I don't remember it in the past). I don't know if it's part of the base VSCode, part of Microsoft's C/C++ extension that I installed, or some combination of both. But the end effect is that when I'm typing in a comment (either // or /* */ style), the autocomplete popup decides to show itself when it sees text that it knows. An example:
Similar things happen when I'm typing a period to end a sentence. Autocomplete sees this as an opportunity to try to turn a simple period into a dereference to a member.
The issue is that while having autocomplete do this on code is exactly what I want, having it do this when I'm typing comments is exactly what I don't.
The text was updated successfully, but these errors were encountered: