I'm using Monaco 0.22.2 trying to bring up suggestions for function parameters. I've defined a simple example like so:
monaco.languages.registerSignatureHelpProvider('myCustomLang', {
signatureHelpTriggerCharacters: ['(', ','],
provideSignatureHelp: (model, position, token) => {
return {
activeParameter: 0,
activeSignautre: 0,
signatures: [{
label:'string of_string(string $string, int $start)',
parameters: [
{
label: 'string $string',
documentation: 'The input string'
},
{
label: 'int $start',
documentation: "if $start is non-negative...",
}
]
}]
};
}
});
However as soon as I type in "(" or "," to trigger this code, I get the error:
Cannot read property 'signatures' of undefined
TypeError: Cannot read property 'signatures' of undefined
at ParameterHintsModel.eval (parameterHintsModel.js:166)
at Generator.next (<anonymous>)
at fulfilled (parameterHintsModel.js:19)
at eval (errors.js:24)
What am I doing wrong? My regular simple suggestions show up, but I can't get potential function parameter suggestions to show up.
The response should be structured this way:
monaco.languages.registerSignatureHelpProvider("myCustomLang", {
signatureHelpTriggerCharacters: ["(", ","],
provideSignatureHelp: (model, position, token) => {
return {
dispose: () => {},
value: {
activeParameter: 0,
activeSignature: 0,
signatures: [
{
label:
"string substr(string $string, int $start [, int $length])",
parameters: [
{
label: "string $string",
documentation:
"The input string. Must be one character or longer.",
},
{
label: "int $start",
documentation:
"If $start is non-negative, the returned string will start at the $start'th position in string, counting from zero. For instance, in the string 'abcdef', the character at position 0 is 'a', the character at position 2 is 'c', and so forth.\r\nIf $start is negative, the returned string will start at the $start'th character from the end of string. If $string is less than $start characters long, FALSE will be returned.",
},
{
label: "int $length",
documentation:
"If $length is given and is positive, the string returned will contain at most $length characters beginning from $start (depending on the length of $string) If $length is given and is negative, then that many characters will be omitted from the end of $string (after the start position has been calculated when a start is negative). If $start denotes the position of this truncation or beyond, FALSE will be returned. If $length is given and is 0, FALSE or NULL, an empty string will be returned. If $length is omitted, the substring starting from $start until the end of the string will be returned.",
},
],
},
],
},
};
},
});
The response type is SignatureHelpResult, it should have a value and dispose method. The value should be SignatureHelp with activeParameter activeSignature and signatures
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With