Skip to content

Fix: Return out-of-bounds index instead of -1 for activeParameter - #3580

Merged
fbricon merged 4 commits into
eclipse-jdtls:mainfrom
tartarughina:main
Oct 31, 2025
Merged

fbricon merged 4 commits into
eclipse-jdtls:mainfrom
tartarughina:main

Conversation

@tartarughina

Copy link
Copy Markdown
Contributor

This PR fixes #2434.

Problem

The signature help was returning activeParameter = -1 when no parameter is active (e.g., when the cursor is at the opening parenthesis of a method call). This violates the LSP specification and breaks signature help rendering in clients like Neovim with cmp-nvim-lsp or Zed, which cannot handle negative parameter indices.

Solution

Instead of returning -1 when there's no active parameter, this PR returns the number of parameters in the signature. This ensures the activeParameter index is always out of bounds (when no parameter should be highlighted), which adheres to the LSP spec and prevents clients from incorrectly highlighting parameters.

Example

Before:

System.out.println( |);  // activeParameter = -1 (breaks clients)

After:

System.out.println( |);  // activeParameter = 1 (for "println(Object x)" signature with 1 parameter)

tartarughina and others added 3 commits October 22, 2025 22:33
When there's no active parameter, return the number
of parameters rather than -1

Implements what suggested at
eclipse-jdtls#2434
@eclipse-ls-bot

Copy link
Copy Markdown
Contributor

Can one of the admins verify this patch?

- Adjust tests by expecting number of parameters rather than -1
@fbricon

fbricon commented Oct 31, 2025

Copy link
Copy Markdown
Contributor

add to whitelist

@fbricon
fbricon merged commit 1c2dbd5 into eclipse-jdtls:main Oct 31, 2025
2 checks passed
@fbricon

fbricon commented Oct 31, 2025

Copy link
Copy Markdown
Contributor

Works fine with vscode. Aligns with the spec, all good for me. Thanks @tartarughina!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

signatureHelp returns activeParameter = -1

3 participants