Skip to content

[Bug] autocompletion does not work inside strings #2883

Closed

Description

@fdrag

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Code

monaco.editor.create(document.getElementById('container'), {
	value: "function hello() {\n\talert('Hello world!');\n}",
	language: 'typescript'
});

Actual Behavior

unknown

help

Expected Behavior

show autocompletion

Additional Context

if not bug then how to implement string completion? (sorry bad english )

Activity

  1. rcjsuen commented on Jan 9, 2022

    @rcjsuen
    Contributor

    image

    fdrag Seems fine to me. 🤔

  2. fdrag commented on Jan 9, 2022

    @fdrag
    Author

    image

    fdrag Seems fine to me. 🤔

    xBeOt1Z9GW.mp4
  3. fdrag commented on Jan 9, 2022

    @fdrag
    Author

    it still not working for me, how to implement string autocompletion myself?

    i want to copy this
    image

  4. rcjsuen commented on Jan 9, 2022

    @rcjsuen
    Contributor

    it still not working for me, how to implement string autocompletion myself?

    If you invoke Intellisense explicitly with Control+Space (or Cmd+Space on macOS) it works.

    i want to copy this image

    What is this from?

  5. fdrag commented on Jan 9, 2022

    @fdrag
    Author

    it is from visual studio code, im trying to making my own monaco editor for testing purposes but im not knowing how to implement those

    how to automatic invoke intellisense when in qoutes?

  6. rcjsuen commented on Jan 9, 2022

    @rcjsuen
    Contributor

    export class SuggestAdapter extends Adapter implements languages.CompletionItemProvider {
    public get triggerCharacters(): string[] {
    return ['.'];
    }

    1. At a surface level, the obvious issue is that the trigger characters in Visual Studio Code are not the same as Monaco's (per above). We can see Monaco does not invoke Intellisense as aggressively as VS Code.

    /**
    * Enable quick suggestions (shadow suggestions)
    * Defaults to true.
    */
    quickSuggestions?: boolean | IQuickSuggestionsOptions;

    1. Another issue is that quickSuggestions seems to be false when it supposedly defaults to being true. Turning it on explicitly seems to fix your problem. Please try the code below, fdrag.
    const content = `interface env {
    	a: "abc" | "def";
    }
    let env: env = {
    	a: ""
    }`;
    monaco.editor.create(document.getElementById('container'), {
        value: content,
        language: 'typescript',
        quickSuggestions: true
    });
  7. rcjsuen commented on Jan 9, 2022

    @rcjsuen
    Contributor
    const defaults: ValidQuickSuggestionsOptions = {
        other: true,
        comments: false,
        strings: false
    };

    I think this is the issue. Quick suggestions are enabled by default...they're just not enabled by default if the text caret is inside a comment or a string. The comment should be updated to reflect this in my opinion.

  8. fdrag commented on Jan 9, 2022

    @fdrag
    Author
    ValidQuickSuggestionsOptions 

    Thank you for your explanation. :D

  9. locked and limited conversation to collaborators on Mar 3, 2023
  10. converted this issue into a discussion #3679 on Mar 3, 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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions