monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

[Bug] SQL dialect does not work

Open nfiacco opened this issue 2 years ago • 5 comments

Reproducible in vscode.dev or in VS Code Desktop?

  • [X] 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: "",
	language: 'sql'
});

Reproduction Steps

Simply type select * from f in the playground editor.

Actual (Problematic) Behavior

The editor suggests "from" when you type the "f", which doesn't make sense. "Select" and "from" are not autosuggested.

Expected Behavior

"Select" and "from" should be suggested, and table names (if provided) should be suggested after "from".

Additional Context

No response

nfiacco avatar Sep 13 '22 23:09 nfiacco

The editor suggests "from" when you type the "f", which doesn't make sense.

You can disable it via wordBasedSuggestions: false

"Select" and "from" should be suggested, and table names (if provided) should be suggested after "from".

This can be implemented using a CompletionItemProvider, it's nothing Monaco has built in

https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-completion-provider-example https://microsoft.github.io/monaco-editor/api/interfaces/monaco.languages.CompletionItemProvider.html

Prinzhorn avatar Sep 15 '22 08:09 Prinzhorn

That makes sense, but shouldn't it work given that the SQL option is available?

nfiacco avatar Sep 16 '22 23:09 nfiacco

The language option is for syntax highlighting https://microsoft.github.io/monaco-editor/monarch.html Autocomplete is an entirely separate thing. You can't expect Monaco to ship with autocomplete support for every language and every SQL flavor.

From the website https://microsoft.github.io/monaco-editor/

image

Prinzhorn avatar Sep 17 '22 07:09 Prinzhorn

That makes sense, I guess why is there any autocomplete whatsoever? Wouldn't it be better if it didn't suggest anything?

nfiacco avatar Sep 18 '22 17:09 nfiacco

That makes sense, I guess why is there any autocomplete whatsoever? Wouldn't it be better if it didn't suggest anything?

Depends who you ask. I imagine there are users that like word-based suggestions which is why it is enabled by default.

rcjsuen avatar Sep 18 '22 21:09 rcjsuen

This is out of scope.

hediet avatar Dec 13 '22 15:12 hediet