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

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

Closed
tomasbaran opened this issue Mar 15, 2021 · 9 comments
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

@tomasbaran
Copy link

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"
@DanTup DanTup changed the title Code completion doesn't trigger automatically for import snippets Code completion doesn't trigger automatically for imports in LSP Mar 16, 2021
@DanTup DanTup added this to the On Deck milestone Mar 16, 2021
@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 labels Mar 16, 2021
@DanTup
Copy link
Member

DanTup commented Mar 16, 2021

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.

@tomasbaran
Copy link
Author

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

@tomasbaran
Copy link
Author

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

@DanTup
Copy link
Member

DanTup commented Mar 16, 2021

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!

@tomasbaran
Copy link
Author

tomasbaran commented Mar 16, 2021

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

@DanTup
Copy link
Member

DanTup commented Mar 16, 2021

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!

@tomasbaran
Copy link
Author

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

Cheers,

@DanTup DanTup modified the milestones: On Deck, v3.22.0 Mar 26, 2021
@DanTup DanTup 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 Apr 15, 2021
@tomasbaran
Copy link
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

@DanTup
Copy link
Member

DanTup commented Jun 9, 2021

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

2 participants