If I've a class A with doSomething() method defined on it and I do this -
A a;
a.doSo
it pops up doSomething as autocompletion. If I select it, it completes the word to a.doSomething. Notice that doSomething isn't a member var but a member method so correct behaviour should be a.doSomething() with cursor in b/w the parenthesis.
This is currently the expected behavior. We do not auto-insert parenthesis as part of auto-complete for functions. VS Code does not allow the extensions to insert code and move the cursor at the same time. If you would like to have this feature in VS Code, I would suggest opening an feature request for them to implement this. Here's the link to their issues list: https://github.com/Microsoft/vscode/issues
@bobbrow I had opened issue on vscode where they hint towards this already being possible!
@bobbrow this is currently possible using snippets which let you control the cursor position.
Ok then. We can add this to our backlog.
Our latest 0.21.0-insiders3 triggers completion when ( is used. Is that good enough or is adding the () on Enter/Tab/Click, still desired?
Setting C_Cpp.updateChannel to "Insiders" is another way to get the update.
Dear @sean-mcmanus, IMO It's mostly useful to autocomplete a function name with the parentheses with both () and cursor in between.
Design Ideology:- Keep hands always on the three Keyboard rows(z,a and q row) and especially avoid pressing combination keys(Shift+(). Pressing enter, semicolon, and left right keys is not a pain-point at all compared to pressing Shift+(). Another thing is if I am pressing (, I always add a ) immediately to it, so its always same effort as a single key stroke(actually two if we count shift). Thus if you only provide (, it still needs nearly the same effort as before.
Of course having options to enable or disable this behavior or configure it custom needs would be beneficial for users with different opinion.
@saurabheights Typing obj.f(| yields obj.func(|), so the ) is completed with the cursor in between -- have you tried it out in 0.21.0-insiders3? Yeah, for users who don't want to type ( we would have to implement an additional solution...maybe I'll open a new bug for that or maybe just keep one of these issues open.
Dear @sean-mcmanus , Yes, I did try, just before posting my last comment, and current behavior is as you say :) .
Also, no need for another issue. This was the original request by the issue creator and I just wanted to drop my thoughts on why the original request makes sense in being the default behavior(as stated in my previous comment in Design Ideology).
FYI, our next Insider release will remove the ( commitCharacter (due to https://github.com/Microsoft/vscode-cpptools/issues/3127), but replace it with the "(|)" snippet, which is a "better" experience anyway.
@dbaeumer We attempted to use snippets to add (|) but setting the CompletionItem.command to invoke signature help doesn't cause the signature help UI to appear: see https://github.com/Microsoft/vscode/issues/67901 .
UPDATE: It got resolved.
You can try to use the action editor.action.triggerParameterHints which should show the UI.
@dbaeumer Yeah, thanks that worked. The docs were confusing when I searched for signature help apis (https://github.com/Microsoft/vscode/issues/67901#issuecomment-460776059).
Is this now in the stable version? If so, how do I turn this feature on?
@johnknoop The fix got reverted due to it causing unexpected regressions, and the alternative fix using "snippets" got post-poned until we can add some setting like methodCompletion: "AddNoParens", "AddLeftParen", "AddBothParens".
Is this on insiders? How can we enable it?
@robot110011 No, the issue got "postponed" (see my last comment).
@sean-mcmanus any chance to see the fix come back one day?
@Nimamoh Yeah, my PR still exists on the server-side -- if anyone wants to submit a PR on the TypeScript side to add some methodCompletion setting that would help. We've been pretty busy with higher priority stuff...not sure when our schedule would free up more to finish this.
Hello @sean-mcmanus I recently tried vscode and i found everything perfect i tried to move on from sublime but my only concern is that i can't insert parenthesis in auto-completing Methods
like when i type str_replace and select it from auto-completion box and press enter it should be str_replace(|) and cursor in between i searched a lot and couldn't find anything can you help me or let me know is this possible in vscode maybe in future version? Thanks
@nomanaadma We're tracking it with https://github.com/microsoft/vscode-cpptools/issues/882 . It seems to have a lot of upvotes, but it's not on our scheduled work yet.
It can be solved by ticking javascript.suggest.completeFunctionCalls property up. Here is the gif.
@akrsnr the solution you provided worked for javascript/typescript files but it didn't work for any other languages
@akrsnr How are you getting that awesome IntelliSense while you are typing the code? Is that an extension?
@rishav394 it is a built in feature of vscode
@akrsnr Strange. I don't get that kind of intellisense. Atleast not on the stable version of vscode. That's so useful.
@rishav394 Try setting the following in your settings, not sure though!
"editor.quickSuggestionsDelay": 0
Most helpful comment
Dear @sean-mcmanus, IMO It's mostly useful to autocomplete a function name with the parentheses with both
()and cursor in between.Design Ideology:- Keep hands always on the three Keyboard rows(z,a and q row) and especially avoid pressing combination keys(
Shift+(). Pressing enter, semicolon, and left right keys is not a pain-point at all compared to pressing Shift+(). Another thing is if I am pressing(, I always add a)immediately to it, so its always same effort as a single key stroke(actually two if we count shift). Thus if you only provide(, it still needs nearly the same effort as before.Of course having options to enable or disable this behavior or configure it custom needs would be beneficial for users with different opinion.