Crash on invoking function signature.
See original GitHub issuemonaco-editor version: 0.14.3 Browser: Chrome 67.0.3396.99 OS: macOS 10.12
Okay, it seems like a VS Code issue from where the crash happens, but since I am using Monaco, I am filing it here.
I am using Monaco editor connected with a backend language server. When trying to invoke displaying the signature of a function, I am seeing a crash with the following call stack in the browser console:
errors.js:58 Uncaught Error: Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at ParameterHintsWidget.render (parameterHintsWidget.js:272)
at parameterHintsWidget.js:182
at Emitter.fire (event.js:105)
at parameterHintsWidget.js:104
at ParameterHintsWidget.render (parameterHintsWidget.js:272)
at parameterHintsWidget.js:182
at Emitter.fire (event.js:105)
at parameterHintsWidget.js:104
at errors.js:58
The Monaco client sends a request like this:
{"jsonrpc":"2.0","id":6,"method":"textDocument/signatureHelp","params":{"textDocument":{"uri":"/home/model.r"},"position":{"line":36,"character":6}}}
And the language server responds with:
{"jsonrpc":"2.0","id":6,"result":{"signatures":[{"label":"paste(..., sep = \" \", collapse = NULL)"}],"activeSignature":0}}
This happens because of the following line inside ParameterHintsWidget’s render function:
var hasParameters = signature.parameters.length > 0;
This line assumes that parameters
field always present inside signature
, while in fact parameters is absent from the server response above. However, the LSP specification says SignatureInformation’s parameters is optional. Therefore, the assumption doesn’t seem correct.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
@hifall That’s the LSP specification and not the Monaco/VS Code API. They may look like they are 1-to-1 but they do not have to be 1-to-1.
It’s up to bridges like the TypeFox/monaco-languageclient and Microsoft/vscode-languageserver-node projects to alter LSP information into a way that is consumable by the client editor.
The official spec says it’s optional: LSP spec, search for
SignatureInformation
.