microsoft / monaco-editor

A browser based code editor

Home Page:https://microsoft.github.io/monaco-editor/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Autosuggestion doesn't show up with any character excpet '@'.

Chrisberou opened this issue · comments

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 Link

No response

Monaco Editor Playground Code

registerAutocomplete() {
            this.propsCompletionProvider = monaco.languages.registerCompletionItemProvider('javascript', {
        provideCompletionItems: (model,position) => {
            const range=this.getRange(model,position);
          return {
             suggestions: this.propSuggestions.map((suggestion)=>{
                //console.log('prop suggestion:', JSON.stringify(suggestion, null, 2));
            return{
                ...suggestion,
                range,
            }
          })};
        },
        resolveCompletionItem: (item) => {
          const prop = this.meta?.propsComponent?.filter((apiProp) => {if(apiProp.name === item.label){return apiProp.name}});
          if (!prop) return item;
          return {
            ...item,
            insertText: `${this.getPropPrefix(prop)}${prop.name}="${prop.defaultValue?.name?? ''}"`,
          };
        },
      });
      this.eventsCompletionProvider = monaco.languages.registerCompletionItemProvider('javascript', {
         triggerCharacters:['@'],
        provideCompletionItems: (model,position) => {
            const range=this.getRange(model,position);
          return {
             suggestions: this.eventSuggestions.map((suggestion)=>{
                //console.log('event suggestion:', JSON.stringify(suggestion, null, 2));
            return{
                ...suggestion,
                range,
            }
          })};
        },
      });

Reproduction Steps

No response

Actual (Problematic) Behavior

i have created a small monaco editor that is like "how to use" and shows a part of the code of how you can use this widget on your code and i want it when someone wants to change the properties and the events , the monaco to show suggestions on those events and properties. The issue is that i have created two providers one for properties and one for the events and for the event provider i have '@' as a trigger character and it works perfect ,but the prop provider doesn't work by default with alphabet character and even if set a trigger character still the suggestion dropdown doesn't show up except if i set the prop provider also with '@' as trigger character.

I tried to also set the trigger character manually for every alphabet character and still nothing .

Expected Behavior

No response

Additional Context

No response