Skip to content

Code completion doesn't trigger automatically for imports/slashes/interpolation in LSP #3211

Closed

Description

@tomasbaran

Describe the bug
It doesn't autocomplete package in VS Code. It's a pain in the butt now.

To Reproduce
Steps to reproduce the behavior:

  1. write import 'mate

Expected behavior
import 'package:flutter/material.dart';

Screenshots

Captura de pantalla 2021-03-15 a las 21 17 55

Versions (please complete the following information):

  • VS Code version: 1.54.2
  • Dart extension version: Awesome Flutter Snippets: v2.0.4
  • Flutter (Channel beta, 2.0.1, on macOS 11.1 20C69 darwin-x64, locale es-ES)
  • Dart SDK version: 2.10.5 (stable) (Tue Jan 19 13:05:37 2021 +0100) on "macos_x64"

Activity

  1. changed the title [-]Code completion doesn't trigger automatically for import snippets[/-] [+]Code completion doesn't trigger automatically for imports in LSP[/+] on Mar 16, 2021
  2. added this to the On Deck milestone on Mar 16, 2021
  3. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    on Mar 16, 2021
  4. DanTup commented on Mar 16, 2021

    @DanTup
    Member

    Thanks for the issue! This is a known limitation when using LSP that hasn't been resolved yet.

    In case you're not away - you can manually invoke completion with Cmd/ Ctrl+Space which will open the list. The only thing missing is that it doesn't open automatically when pressing the '.

    I'll keep this issue open to track supporting this in LSP.

  5. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    and removed on Mar 16, 2021
  6. tomasbaran commented on Mar 16, 2021

    @tomasbaran
    Author

    Thanks @DanTup but how come this issue was NOT present before?

  7. tomasbaran commented on Mar 16, 2021

    @tomasbaran
    Author

    @DanTup Please, how can I manually invoke completion again? pressing cmd+space on Mac opens the macOS search Spotlight.

  8. DanTup commented on Mar 16, 2021

    @DanTup
    Member

    Thanks @DanTup but how come this issue was NOT present before?

    In the original code there are some hacks to make this work:

    if (context.triggerKind === CompletionTriggerKind.TriggerCharacter) {
    switch (context.triggerCharacter) {
    case "{":
    return line.endsWith("${");
    case "'":
    return line.endsWith("import '") || line.endsWith("export '");
    case "\"":
    return line.endsWith("import \"") || line.endsWith("export \"");
    case "/":
    case "\\":
    return line.startsWith("import \"") || line.startsWith("export \"")
    || line.startsWith("import '") || line.startsWith("export '");
    }
    }

    We're in the process of moving to LSP for the language server, which isn't so easy to do something like that. It's possible to fix (and will be fixed), but it wasn't considered critical for the migration so hasn't been done yet.

    pressing cmd+space on Mac opens the macOS search Spotlight.

    Sorry, I gave the wrong combo - it's Ctrl+Space even on Mac!

  9. tomasbaran commented on Mar 16, 2021

    @tomasbaran
    Author

    Sorry, I gave the wrong combo - it's Ctrl+Space even on Mac!

    My mac (I guess all do but maybe I'm wrong) have ctrl+space is set for changing keyboard language. Even when I undo this system shortcut, autocompletion still does NOT work. Any tips, please?
    Captura de pantalla 2021-03-16 a las 11 13 35
    Captura de pantalla 2021-03-16 a las 11 13 47

  10. DanTup commented on Mar 16, 2021

    @DanTup
    Member

    I don't know why it wouldn't work - it's VS Code functionality rather than Dart, but you can see/re-bind the shortcut in the VS Code Keyboard Shortcuts editor. (it's the top item here called "Trigger Suggest"):

    Screenshot 2021-03-16 at 11 21 39

    Hope this helps!

  11. tomasbaran commented on Mar 16, 2021

    @tomasbaran
    Author

    Thanks. Maybe all I had to was restart the IDE after unselecting the system shortcut for changing keyboard language.

    Cheers,

  12. modified the milestones: On Deck, v3.22.0 on Mar 26, 2021
  13. changed the title [-]Code completion doesn't trigger automatically for imports in LSP[/-] [+]Code completion doesn't trigger automatically for imports/slashes/interpolation in LSP[/+] on Apr 15, 2021
  14. tomasbaran commented on Jun 7, 2021

    @tomasbaran
    Author

    @DanTup Is the issue fixed? If so, what do I have to do to make it work on my end? As far as I know I'm still not experiencing auto completion of import

  15. DanTup commented on Jun 9, 2021

    @DanTup
    Member

    @tomasbaran it depends on the exact context you're having issues with.

    If the problem is that when you type a quote after import or a / inside the path (note: type manually, and not have them included by a completion) then the fix is in the SDK, so you'll need an updated SDK for the fix (it's not in the current stable channel, but should be in the dev channels of Dart/Flutter).

    If the problem is when you select the import ''; snippet from the completion list, or you select a folder in the completion list, then that's fixed for the next version of Dart-Code (#3385).

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