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

Provide configuration for deleting trigger characters after providing pop-up lists

Open git102347501 opened this issue 1 year ago • 1 comments

Context

  • [X] This issue is not a bug report. (please use a different template for reporting a bug)
  • [X] This issue is not a duplicate of an existing issue. (please use the search to find existing issues)

Description

I hope that after entering @, a dropdown list will pop up for selection. After selection, the @ symbol needs to be removed, similar to: selecting test from the @ dropdown, and ultimately staying in the editor is test instead of @ test

Monaco Editor Playground Link

demo

Monaco Editor Playground Code

const value = /* set from `myEditor.getModel()`: */ `@`;

// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
	value: "",
	language: "sql"
});

monaco.languages.registerCompletionItemProvider('sql', {
      triggerCharacters: ['@'],
      provideCompletionItems: (model, position) => {
        let suggestions = [{label: "test", kind: "test", insertText: "test"}];
        return { suggestions };
	  }
	}
);

git102347501 avatar Jan 07 '24 14:01 git102347501

monaco.languages.registerCompletionItemProvider('sql', {
      triggerCharacters: ['@'],
      replaceTriggerChar: true, // For example, if this configuration is enabled, @ will be replaced
      provideCompletionItems: (model, position) => {
        let suggestions = [{label: "test", kind: "test", insertText: "test"}];
        return { suggestions };
	  }
	}
);

git102347501 avatar Jan 07 '24 14:01 git102347501