Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[Bug] autocompletion does not work inside strings #2883

Closed
1 of 2 tasks
fdrag opened this issue Jan 9, 2022 · 8 comments
Closed
1 of 2 tasks

[Bug] autocompletion does not work inside strings #2883

fdrag opened this issue Jan 9, 2022 · 8 comments
Labels

Comments

@fdrag
Copy link

fdrag commented Jan 9, 2022

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 )

@rcjsuen
Copy link
Contributor

rcjsuen commented Jan 9, 2022

image

@fdrag Seems fine to me. 🤔

@fdrag
Copy link
Author

fdrag commented Jan 9, 2022

image

@fdrag Seems fine to me. 🤔

xBeOt1Z9GW.mp4

@fdrag
Copy link
Author

fdrag commented Jan 9, 2022

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

i want to copy this
image

@rcjsuen
Copy link
Contributor

rcjsuen commented Jan 9, 2022

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?

@fdrag
Copy link
Author

fdrag commented Jan 9, 2022

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?

@rcjsuen
Copy link
Contributor

rcjsuen commented Jan 9, 2022

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
});

@rcjsuen
Copy link
Contributor

rcjsuen commented Jan 9, 2022

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.

@fdrag
Copy link
Author

fdrag commented Jan 9, 2022

ValidQuickSuggestionsOptions 

Thank you for your explanation. :D

@microsoft microsoft locked and limited conversation to collaborators Mar 3, 2023
@hediet hediet converted this issue into discussion #3679 Mar 3, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

3 participants