scalameta / metals

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

Odd completions ordering for ZIO #4181

Open kpodsiad opened 2 years ago

kpodsiad commented 2 years ago

Describe the bug

scala-cli reproduction

//> using scala "3.1.3"
//> using lib "dev.zio::zio:2.0.0"

import zio._

object ZioOrdering extends ZIOAppDefault {

  val task = ZIO.succ@@
  override def run = ???
}
  1. Type ZIO.succ@@
  2. succeed isn't the first completion option Screenshot 2022-07-21 at 19 27 49

Expected behavior

Completions for ZIO.succ@@ should return succedd as the first option.

succeedBlockingUnsafe and succeedUnsafe are members of ZIO, where succeed comes from extending ZIOCompanionVersionSpecific. I suspect that's why such ordering is obtained but I didn't go through code to confirm that.

Operating system

macOS

Editor/Extension

VS Code

Version of Metals

v.0.11.7

Extra context or search terms

completions ordering zio

dos65 commented 2 years ago

@kpodsiad could you also ensure that it's an ordering issue on Metals side (from lsp trace)? Vscode sometimes changes the order.

kpodsiad commented 2 years ago

I forgot about that vscode can alter this, thanks for reminding @dos65. I've checked and it's Metals issue,

[Trace - 08:42:07 PM] Sending response 'textDocument/completion - (32)'. Processing request took 232ms
Result: {
  "isIncomplete": false,
  "items": [
    {
      "label": "succeedBlockingUnsafe[A](a: Unsafe \u003d\u003e A)(implicit trace: Trace): UIO[A]",
      "kind": 2,
      "tags": [],
      "detail": "[A](a: Unsafe \u003d\u003e A)(implicit trace: Trace): UIO[A]",
      "sortText": "00000",
...
    }
...
    {
      "label": "succeed[A](a: (Unsafe) ?\u003d\u003e A)(implicit trace: Trace): ZIO[Any, Nothing, A]",
      "kind": 2,
      "tags": [],
      "detail": "[A](a: (Unsafe) ?\u003d\u003e A)(implicit trace: Trace): ZIO[Any, Nothing, A]",
      "sortText": "00002",
    ...
    }
...
dos65 commented 2 years ago

@kpodsiad thanks for confirming!