Skip to content

Completion does not trigger automatically when typing inside an string interpolation expression #4808

Closed

Description

@incendial

Describe the bug
Good:

Screen.Recording.2023-10-23.at.15.51.38.mov

Bad:

Screen.Recording.2023-10-23.at.15.52.39.mov

Note: when you see the completion menu disappearing, it's me pressing Esc.

Please complete the following information:

Dart Code extension: 3.74.0

App: Visual Studio Code
App Host: desktop
Version: mac 1.83.1

Workspace type: Dart (LSP)

Dart (3.2.0-210.1.beta): /Users/dimannich/Desktop/flutter/bin/cache/dart-sdk
Flutter (3.16.0-0.1.pre): /Users/dimannich/Desktop/flutter

Activity

  1. DanTup commented on Oct 23, 2023

    @DanTup
    Member

    I presume the issue here is that it's not automatically triggering completion when you type a after the dot (and triggering it manually gives the expected result)?

    Triggering on alphanumerics is handled by VS Code, not Dart. We set explicit triggering on dot (which seems to work in your video).

    What's odd, is I can reproduce the issue with Dart:

    class A {
      final List<String> allowedPrefixes = [];
    }
    
    void f(A a) {
      return '${a.}'; // Type 'a' after the dot
    }

    But I can't repro with TypeScript:

    class A {
    	public allowedPrefixes = [];
    }
    
    function f(a: A) {
    	return `${a.}`; // Type 'a' after the dot
    }

    Yet TypeScripts trigger characters look mostly the same as ours (specifically, 'a' is not listed):

    https://github.com/microsoft/vscode/blob/c6dcdc753ba263e321e907eb92270ea18ef19ee8/extensions/typescript-language-features/src/languageFeatures/completions.ts#L660

    I've verified in the logs that VS Code doesn't seem to send the request to the server, so it's not that the server is filtering it our (or returning no results).

    Needs some digging!

  2. DanTup commented on Oct 23, 2023

    @DanTup
    Member

    The plot thickens... if you use backticks instead of single quotes in Dart, it also works (ofcourse this is invalid dart).

  3. added this to the v3.76.0 milestone on Oct 23, 2023
  4. added
    in editorRelates to code editing or language features
    on Oct 23, 2023
  5. incendial commented on Oct 23, 2023

    @incendial
    Author

    Do we need a proposal to make it valid Dart then? 😁 (sorry).
    How to NOT solve issues properly 😁.

  6. incendial commented on Oct 23, 2023

    @incendial
    Author

    On a serious note, I didn't try to invoke this menu manually. Let me know if you need me to check this.

  7. DanTup commented on Oct 23, 2023

    @DanTup
    Member

    You could check (Cmd+Space / Ctrl+Space), though I suspect it'll work fine and the issue here is just triggering, since I can repro what I described above reliably. I suspect it'll require digging through the VS Code source to understand what's happening.

  8. incendial commented on Oct 23, 2023

    @incendial
    Author

    Neither Cmd nor ctrl work for me (probably there is another shortcut for mac). Do you how it's called?

    I suspect it'll require digging through the VS Code source to understand what's happening.

    Would be kinda funny if they left a hack for TS or something 😅

  9. changed the title [-]Completion stops working inside an interpolation[/-] [+]Completion stops automatically showing when typing inside an interpolation[/+] on Oct 23, 2023
  10. DanTup commented on Oct 23, 2023

    @DanTup
    Member

    If you find the "Trigger Suggest" command in the palette, that should show the key binding.

    To confirm - you're pressing it after typing the a?

  11. incendial commented on Oct 23, 2023

    @incendial
    Author
    Screenshot 2023-10-23 at 16 47 15

    Yeah, ctrl space changes current language for me (you probably don't have this at all), so I assume OS intercepts it. Cmd + I worked and can confirm that it works inside the interpolation.

  12. DanTup commented on Oct 23, 2023

    @DanTup
    Member

    Seems to be related to this code here. When you press a, it's asking whether quick-suggestions are enabled before triggering completion. By default (or at least for me), it's disabled for strings+comments but enabled for other. For TS, this expression is "other" but for Dart it's "string", which is why in TS it triggers and for Dart it doesn't.

    image

    So, we'll need to do some investigation into the tokens being produced here.

  13. incendial commented on Oct 23, 2023

    @incendial
    Author

    So it basically fails to recognise that it's an interpolation? Interesting.

  14. DanTup commented on Oct 23, 2023

    @DanTup
    Member

    By "it", we probably mean the Dart textmate grammar or semantic tokens, and it could just be that our names don't match what it expects (the method is called getStandardTokenType so it might be doing some guesswork to understand which tokens are strings/comments/code for each language).

    I'll have to do some more digging, will come back to this soon :)

  15. DanTup commented on Oct 26, 2023

    @DanTup
    Member

    image

    I wonder if it's because these start with string.

    For TypeScript there is still a string prefix, but there's also meta and punctuation. "Standard token type" is "other".

    image

  16. DanTup commented on Oct 26, 2023

    @DanTup
    Member

    I can't figure out how this works - even using the same TS scope name produces "String". I've filed an issue asking for some docs:

    microsoft/vscode#196725

  17. changed the title [-]Completion stops automatically showing when typing inside an interpolation[/-] [+]Completion does not trigger automatically when typing inside an string interpolation expression[/+] on Oct 26, 2023
  18. modified the milestones: v3.76.0, v3.78.0 on Oct 30, 2023
  19. modified the milestones: v3.78.0, Backlog on Nov 23, 2023
  20. modified the milestones: Backlog, v3.80.0 on Dec 4, 2023
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 featuresis bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions