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

Suggestion Proposal List is not showing if proposal start with non alphabet character

Open chenjunweii opened this issue 6 years ago • 1 comments

  • "awd" : works fine
  • "a<" : works fine
  • ">b" : proposal list not showing
  • ">" : proposal list not showing
const arrOperators = ["a<", ">b",  ">", "awd"]
const createOperatorProposals = (range) => {
  
  return arrOperators.map((v) => ({ 
    label : v,
    filterText : v,
    insertText : v,
    range: range
  }))
}

Any Idea ?

chenjunweii avatar May 20 '20 06:05 chenjunweii

@chenjunweii Works fine for me in the Monaco Editor Playground.

const arrOperators = ["a<", ">b",  ">", "awd"]
const createOperatorProposals = (range) => {
  return arrOperators.map((v) => ({ 
    label : v,
    filterText : v,
    insertText : v,
  }))
}

monaco.languages.registerCompletionItemProvider('json', {
    provideCompletionItems: function(model, position) {
        const word = model.getWordUntilPosition(position);
        const range = {
            startLineNumber: position.lineNumber,
            endLineNumber: position.lineNumber,
            startColumn: word.startColumn,
            endColumn: word.endColumn
        };
        return {
            suggestions: createOperatorProposals(range)
        };
    }
});

monaco.editor.create(document.getElementById("container"), {
    value: "",
    language: "json"
});

image

rcjsuen avatar May 22 '20 16:05 rcjsuen