scalameta / metals

Scala language server with rich IDE features 🚀
https://scalameta.org/metals/
Apache License 2.0
2.1k stars 334 forks source link

Details is duplicated into label in completions, causing odd behaviour in some editor setups #6849

Open Sorixelle opened 1 month ago

Sorixelle commented 1 month ago

Describe the bug

The details value of completion items from the language server seems to be duplicated into the label field. This causes issues with some editors, notably Emacs, using Eglot for LSP support and Corfu for completion:

image

If Corfu is configured for TAB-and-Go completion, typing anything to apply the selected configuration results in the scala.collection.mutable part being left in the file, which is undesired.

To reproduce:

  1. Put together an Emacs configuration using Eglot and Corfu configured for TAB-and-Go completion (if a configuration is necessary, mine is available here, although a little overkill for this repro)
  2. Open a Scala file in a project, ensuring Metals is available on the path
  3. Enable Eglot (if it isn't already) with M-x eglot
  4. Into the buffer, type import scala.collection.mutable.Has
  5. Wait for completions to appear, hit TAB to select an option, and continue typing (eg. type .)
  6. The line becomes import scala.collection.mutable.HashMap scala.collection.mutable.

Expected behavior

When step 5 is completed, the line should become import scala.collection.mutable.HashMap.

Operating system

Linux

Editor/Extension

Emacs (other)

Version of Metals

v1.3.5

Extra context or search terms

No response

tgodzik commented 1 month ago

Thanks for reporting, would need to add a new setting in MetalsServerConfig and the PresentationCompilerConfig which then we can use it around here