You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
LSP code completion should have an option to include parens and/or args #2823
Describe the bug
I'm unable to add parenthesis and give parameters to a function using tab to go to the next parameter.
To Reproduce
Define a function that accepts one or more parameters.
Try to call the function by starting typing it's name and autocompleting it.
See that the only thing that is autocompleted is the name of the function.
Below is a recording of my screen that demonstrates the issue.
Expected behavior
Below is a recording of my screen while I autocomplete a simple console.log() statement. This is how the autocomplemetion on Dart code should've worked.
Insert Argument Placeholder option is enabled and enableCompletionCommitCharacters option is disabled.
Versions (please complete the following information):
Do you have the dart.previewLsp setting enabled? Right now, for LSP commit characters do not work but the general behaviour for completing on functions is to not insert parens, because it's awkward if you don't want to call the function (for example onTap: _handleTap).
The expected fix (once commit characters work correctly) is that you press ( to commit the completion (instead of tab) when you want the parens - that will both commit the highlighted item and insert parens. That way it's easy to control whether they're inserted (enter/tab to just get the name, and ( to invoke).
I couldn't actually repro your TS example - when I complete on console.log I also do not get the parens. If there's some setting you've set that controls this, perhaps we can align the Dart behaviour+settings with it to make it more discoverable. If you know what this is, please let me know!
Yes. I have the dart.previewLsp enabled. The way to complete console.log statement is to enable Complete Function Calls of JS extension. Do commit characters not work right now on Dart Code side?
Commit characters don't currently work on either LSP or not. I'd like to have them working on LSP, though I hit a problem in VS Code that I haven't fixed yet. Hoping to progress that soon.
changed the title [-]Unable to add parenthesis and tab over parameters of a function on autocomplete.[/-][+]LSP code completion should have an option to include parens and/or args[/+]on Nov 11, 2020
When using a new SDK that includes that change, the dart.completeFunctionCalls setting will insert parens/required args (as long as commit characters is not enabled).
❯ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, 1.25.0-4.0.pre, on Microsoft Windows [Version 10.0.19042.662], locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Chrome - develop for the web
[✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.8.2)
[✓] Android Studio (version 4.1.0)
[✓] VS Code (version 1.51.1)
[✓] Connected device (5 available)
• No issues found!
dart-code 3.17.0
Still isn't adding parentheses or argument placeholders.
@Merrit Have you got the LSP preview enabled, and reloaded VS Code since enabling it? I tested with the same version of Flutter and it seems to be included there:
If you're still not seeing it with LSP enabled, please file a new issue and we can capture some logs to understand what's happening. Thanks!
@JoyEnergiser see the comment above. There's a new setting to control this in LSP, but it requires an SDK that includes the setting (which is not currently true of Flutter's stable branch, although it should be in the next major stable release).
Activity
DanTup commentedon Sep 28, 2020
Do you have the
dart.previewLspsetting enabled? Right now, for LSP commit characters do not work but the general behaviour for completing on functions is to not insert parens, because it's awkward if you don't want to call the function (for exampleonTap: _handleTap).The expected fix (once commit characters work correctly) is that you press
(to commit the completion (instead of tab) when you want the parens - that will both commit the highlighted item and insert parens. That way it's easy to control whether they're inserted (enter/tab to just get the name, and(to invoke).I couldn't actually repro your TS example - when I complete on
console.logI also do not get the parens. If there's some setting you've set that controls this, perhaps we can align the Dart behaviour+settings with it to make it more discoverable. If you know what this is, please let me know!SametSahin10 commentedon Sep 28, 2020
Yes. I have the
dart.previewLspenabled. The way to completeconsole.logstatement is to enableComplete Function Callsof JS extension. Do commit characters not work right now on Dart Code side?DanTup commentedon Oct 6, 2020
Commit characters don't currently work on either LSP or not. I'd like to have them working on LSP, though I hit a problem in VS Code that I haven't fixed yet. Hoping to progress that soon.
[-]Unable to add parenthesis and tab over parameters of a function on autocomplete.[/-][+]LSP code completion should have an option to include parens and/or args[/+][Analyzer] Add an LSP setting for including parameters in completions
DanTup commentedon Nov 11, 2020
Fixed by dart-lang/sdk@8687aa6.
When using a new SDK that includes that change, the
dart.completeFunctionCallssetting will insert parens/required args (as long as commit characters is not enabled).Merrit commentedon Nov 11, 2020
Fantastic! Thank you for making this a reality. Look forward to trying it ❤️
Merrit commentedon Dec 4, 2020
Should this be available at this point?
dart-code 3.17.0
Still isn't adding parentheses or argument placeholders.
DanTup commentedon Dec 7, 2020
@Merrit Have you got the LSP preview enabled, and reloaded VS Code since enabling it? I tested with the same version of Flutter and it seems to be included there:
If you're still not seeing it with LSP enabled, please file a new issue and we can capture some logs to understand what's happening. Thanks!
Merrit commentedon Dec 7, 2020
Double checked LSP seems to be enabled.
This does seem to work with something like a function I wrote myself, but not some other things like print() or widgets.
I opened an issue: #2992
DanTup commentedon Dec 7, 2020
Ah, I see. I'll do some digging and follow up in that issue. Thanks!
JoyEnergiser commentedon Jan 23, 2021
I have the same issue, when I disable Dart:Preview LSP then the code completion with parens and/or args works!
DanTup commentedon Jan 25, 2021
@JoyEnergiser see the comment above. There's a new setting to control this in LSP, but it requires an SDK that includes the setting (which is not currently true of Flutter's stable branch, although it should be in the next major stable release).
samariotorres commentedon Feb 16, 2021
still not working for me... tried disabling LSP, tried the recommended
samariotorres commentedon Feb 16, 2021
Sorry got it working, you have to uncheck commit characters as well.