Skip to content

textDocument/signatureHelp's response sometimes has "activeParameter": -1 breaking LSP spec #8087

@igor-ramazanov

Description

@igor-ramazanov

Describe the bug

Sometimes metals returns "activeParameter": -1 for the textDocument/signatureHelp request which breaks some clients1, since it's supposed2 to be a uinteger3.

kakoune-lsp debug log:

LSP: DEBG To server metals: {
  "id": 2277,
  "jsonrpc": "2.0",
  "method": "textDocument/signatureHelp",
  "params": {
    "position": {
      "character": 8,
      "line": 22
    },
    "textDocument": {
      "uri": "file:///<REDACTED>.scala"
    }
  }
}
...
LSP: DEBG From server metals: {
  "id": 2277,
  "jsonrpc": "2.0",
  "result": {
    "activeParameter": -1,
    "activeSignature": 0,
    "signatures": []
  }
}
LSP: ERRO kak-lsp crashed; disabling hooks for this buffer.
Please report an issue or send this crash report.
See the *debug* buffer for more info.

panicked at src/context.rs:257:61:
Failed to parse response: Error("invalid value: integer `-1`, expected u32", line: 0, column: 0)
disabled backtrace
  • Scala: 3.7.4
  • SBT: 1.12.0
  • Scalac flags: -scalajs -Xsemanticdb -semanticdb-target <REDACTED>/target/scala-3.7.4/meta -Wall -Werror -deprecation -feature -no-indent -old-syntax
  • JVM:
    $ java -version
    openjdk version "25" 2025-09-16
    OpenJDK Runtime Environment GraalVM CE 25+37.1 (build 25+37-jvmci-b01)
    OpenJDK 64-Bit Server VM GraalVM CE 25+37.1 (build 25+37-jvmci-b01, mixed mode, sharing)
  • Metals config:
    {
      "autoImportBuild": "all",
      "bloopSbtAlreadyInstalled": false,
      "compilerOptions": {
        "overrideDefFormat": "unicode"
      },
      "defaultBspToBuildTool": false,
      "enableBestEffort": true,
      "enableIndentOnPaste": true,
      "enableSemanticHighlighting": false,
      "icons": "unicode",
      "isExitOnShutdown": false,
      "isHttpEnabled": true,
      "sbtScript": "/run/current-system/sw/bin/sbt",
      "statusBarProvider": "log-message",
      "superMethodLensesEnabled": true,
      "testUserInterface": "Code Lenses",
      "inlayHints": {
        "byNameParameters": {
          "enable": true
        },
        "closingLabels": {
          "enable": true
        },
        "hintsInPatternMatch": {
          "enable": true
        },
        "hintsXRayMode": {
          "enable": true
        },
        "implicitArguments": {
          "enable": true
        },
        "implicitConversions": {
          "enable": true
        },
        "inferredTypes": {
          "enable": true
        },
        "namedParameters": {
          "enable": true
        },
        "typeParameters": {
          "enable": true
        }
      }
    }
  • Linux:
    $ uname --all
    Linux rocksteady 6.18.0 #1-NixOS SMP PREEMPT_DYNAMIC Sun Nov 30 22:42:10 UTC 2025 x86_64 GNU/Linux
  • ScalaJS: 1.20.1

Unfortunately, I don't have a repro, but it consistently happens when:

object Foo {
  def bar(params: Int): Unit = ???
                  ^^^ - whole `Int` is selected
}

object Foo {
  def bar(params: [Int]): Unit = ???
                  ^^^^^ - surrounded with square brackets
}


object Foo {
  def bar(params: O[Int]): Unit = ???
                  ^ - start typing `Option`, and it crashes on `O`
}

Expected behavior

"activeParameter" should never be -1 as specified in the LSP specification.

Operating system

Linux

Editor/Extension

Other

Version of Metals

v1.6.4

Scala version/s

3.7.4

Extra context or search terms

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Scala 3Generic ticket relating to Scala 3presentation-compilerSomething relating to the presentation compilerupstream-fix-neededWaiting on a fix upstream

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions