Skip to content

analysis server: SignatureHelp.activeParameter == -1 violates LSP spec #58577

@notpeter

Description

@notpeter

Apologies if this is not the right place to file this.

The analysis server will generate SignatureHelp objects which violate the LSP by including a -1 for activeParameter -- this value is supposed to be an unsigned integer and you are returning -1. spec link.

image

// TODO(dantup): The LSP spec says this value will default to 0 if it's
// not supplied or outside of the value range. However, setting -1 results
// in no parameters being selected in VS Code, whereas null/0 will select the first.
// We'd like for none to be selected (since we don't support this yet) so
// we send -1. I've made a request for LSP to support not selecting a parameter
// (because you could also be on param 5 of an invalid call to a function
// taking only 3 arguments) here:
// https://github.com/Microsoft/language-server-protocol/issues/456#issuecomment-452318297
activeParameter: -1, // activeParameter

return lsp.SignatureHelp(
signatures: signatures,
activeSignature: 0,
// As with [toSignatureHelp], we don't currently use this, but need to set
// it to something that doesn't match a parameter to avoid one being
// selected.
activeParameter: -1,
);

There is a link in the code to a discussion by @DanTup from 5 years ago:

Which was resolved 9 months later, but the code link with explanation has since gone stale and the code remains.

I am not a dart developer and did not personally experience this, but a discovered a user was having a bad time in Zed because that field is supposed to be an unsigned integer:

The user encountered this on NixOS on aarch64. I'm not sure the version they were running, but looking at the git blame in main it appears this has been the behavior for the last five years. The log in that issue includes the complete response where the user encountered this value of -1.

We can probably fix this on our end in Zed, but I wanted to mention the issue since I saw it in the wild. I haven't dug into how this behaves on neovim, helix or other LSP consumers but out of the box it's broken for Zed.

Thanks!

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work ondevexp-lspIssues with analysis server's support of Language Server Protocoldevexp-serverIssues related to some aspect of the analysis serverlegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions