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

LSP code completion should have an option to include parens and/or args #2823

Closed
SametSahin10 opened this issue Sep 27, 2020 · 13 comments
Closed
Labels
in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is enhancement
Milestone

Comments

@SametSahin10
Copy link

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

  1. Define a function that accepts one or more parameters.
  2. Try to call the function by starting typing it's name and autocompleting it.
  3. 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.

Screen Recording 2020-09-27 at 05 35 10

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.

Screen Recording 2020-09-27 at 05 33 24

Insert Argument Placeholder option is enabled and enableCompletionCommitCharacters option is disabled.

Versions (please complete the following information):

  • VS Code version: 1.49.2
  • Dart extension version: 3.14.1
  • Dart/Flutter SDK version: Dart - 2.9.2 / Flutter - 1.20.4
@DanTup
Copy link
Member

DanTup commented Sep 28, 2020

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!

@DanTup DanTup added awaiting info Requires more information from the customer to progress and removed is bug labels Sep 28, 2020
@SametSahin10
Copy link
Author

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?

@DanTup
Copy link
Member

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

@DanTup DanTup added in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is enhancement and removed awaiting info Requires more information from the customer to progress labels Oct 6, 2020
@DanTup DanTup added this to the On Deck milestone Oct 6, 2020
@DanTup DanTup modified the milestones: On Deck, v3.17.0 Nov 3, 2020
@DanTup DanTup 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 Nov 11, 2020
dart-bot pushed a commit to dart-lang/sdk that referenced this issue Nov 11, 2020
Fixes Dart-Code/Dart-Code#2823.

Change-Id: I477aba5f3563c01a85bb867a1e01f294eed3636e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171585
Commit-Queue: Danny Tuppeny <danny@tuppeny.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
@DanTup
Copy link
Member

DanTup commented Nov 11, 2020

Fixed by dart-lang/sdk@8687aa6.

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

@DanTup DanTup closed this as completed Nov 11, 2020
@Merrit
Copy link

Merrit commented Nov 11, 2020

Fantastic! Thank you for making this a reality. Look forward to trying it ❤️

@Merrit
Copy link

Merrit commented Dec 4, 2020

Should this be available at this point?

❯ 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

image

Still isn't adding parentheses or argument placeholders.

@DanTup
Copy link
Member

DanTup commented 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:

Dec-07-2020 11-50-12

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
Copy link

Merrit commented 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
Copy link
Member

DanTup commented Dec 7, 2020

Ah, I see. I'll do some digging and follow up in that issue. Thanks!

@JoyEnergiser
Copy link

JoyEnergiser commented 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
Copy link
Member

DanTup commented 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
Copy link

samariotorres commented Feb 16, 2021

still not working for me... tried disabling LSP, tried the recommended

@samariotorres
Copy link

still not working for me... tried disabling LSP, tried the recommended

Sorry got it working, you have to uncheck commit characters as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is enhancement
Projects
None yet
Development

No branches or pull requests

5 participants