[Bug] dispose error when using provideSignatureHelp when using model #3688
Replies: 4 comments
-
I don't know the historical reason but you need to implement dispose. (while VSCode extension API does not) var code = "function hello() {\n\talert('Hello world!');\n\tmyFn\n}";
var model = monaco.editor.createModel(code, 'javascript');
monaco.editor.create(document.getElementById('container'), {
model: model
});
monaco.languages.registerSignatureHelpProvider('javascript', {
signatureHelpTriggerCharacters: ['(', ','],
provideSignatureHelp: function(model, position) {
return {
value: {
activeSignature: 0,
activeParameter: 0, // you need to change which parameter is typing
signatures: [{
label: 'blah(blah1, blah2)', // siagnature label must be entire function signature
documentation: 'this method does blah',
parameters: [{
label: 'blah1', // parameter label must be partial of signature label
documentation: 'this param does blah1',
}, {
label: 'blah2', // parameter label must be partial of signature label
documentation: 'this param does blah2'
}]
}]
},
dispose: () => {},
};
}
}); |
Beta Was this translation helpful? Give feedback.
-
Thank you @tamayika! The hint is not closing automatically after type ")". How could I do that manually to fix this problem? Thank you! |
Beta Was this translation helpful? Give feedback.
-
For now my workaround is: provideSignatureHelp: function(model, position) {
var me = this,
currentChar = model.getLineContent(position.lineNumber)[position.column - 2];
// if is typing ")" just close the parameters hint
if (currentChar === ')') {
return {
dispose: () => {},
value: {}
};
}
...
} |
Beta Was this translation helpful? Give feedback.
-
Yes, you need to return empty result when out of call expression. |
Beta Was this translation helpful? Give feedback.
-
Reproducible in vscode.dev or in VS Code Desktop?
Reproducible in the monaco editor playground?
Monaco Editor Playground Code
Reproduction Steps
Type
(p1,p2
after myFnActual (Problematic) Behavior
Console error:
errors.ts:26 Uncaught Error: h.dispose is not a function
TypeError: h.dispose is not a function
at set value [as value] (lifecycle.ts:289:16)
at g. (parameterHintsModel.ts:221:35)
at Generator.next ()
at b (css.ts:80:37)
at errors.ts:26:12
Expected Behavior
No Console errors
Additional Context
Additional Question:
How to implement
provideSignatureHelp
correctly? There is no example using it and documentation doesn't match with return format.I just need to see this when type "(" for first parameter:
And this for second parameter when type ",":
With highlight on each parameter. Besides the bug, could you please help me to implement this?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions