Skip to content

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

Closed

Description

@SametSahin10

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

Activity

  1. DanTup commented on Sep 28, 2020

    @DanTup
    Member

    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!

  2. added
    awaiting infoRequires more information from the customer to progress
    and removed on Sep 28, 2020
  3. SametSahin10 commented on Sep 28, 2020

    @SametSahin10
    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?

  4. DanTup commented on Oct 6, 2020

    @DanTup
    Member

    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.

  5. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    and removed
    awaiting infoRequires more information from the customer to progress
    on Oct 6, 2020
  6. added this to the On Deck milestone on Oct 6, 2020
  7. modified the milestones: On Deck, v3.17.0 on Nov 3, 2020
  8. 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
  9. DanTup commented on Nov 11, 2020

    @DanTup
    Member

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

  10. Merrit commented on Nov 11, 2020

    @Merrit

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

  11. Merrit commented on Dec 4, 2020

    @Merrit

    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.

  12. DanTup commented on Dec 7, 2020

    @DanTup
    Member

    @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!

  13. Merrit commented on Dec 7, 2020

    @Merrit

    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

  14. DanTup commented on Dec 7, 2020

    @DanTup
    Member

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

  15. JoyEnergiser commented on Jan 23, 2021

    @JoyEnergiser

    I have the same issue, when I disable Dart:Preview LSP then the code completion with parens and/or args works!

  16. DanTup commented on Jan 25, 2021

    @DanTup
    Member

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

  17. samariotorres commented on Feb 16, 2021

    @samariotorres

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

  18. samariotorres commented on Feb 16, 2021

    @samariotorres

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions