-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement: Make including detail in completion label configurable
Some LSP clients (such as Emacs using Eglot and Corfu) use the label field to insert a completion if completionItem/resolve has not returned by the time the completion is selected. Including the contents of the detail property in the label causes it to be included in the file itself in these clients. To remedy this, we define a isDetailIncludedInLabel option under compilerOptions to make this behaviour toggleable. We also disable this behaviour by default in Emacs, since this is where the undesirable behaviour was located. Fixes #6849.
- Loading branch information
Showing
8 changed files
with
147 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
tests/cross/src/test/scala/tests/pc/CompletionWithoutDetailsSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package tests.pc | ||
|
||
import scala.meta.internal.pc.PresentationCompilerConfigImpl | ||
import scala.meta.pc.PresentationCompilerConfig | ||
|
||
import tests.BaseCompletionSuite | ||
|
||
class CompletionWithoutDetailsSuite extends BaseCompletionSuite { | ||
|
||
override def config: PresentationCompilerConfig = | ||
PresentationCompilerConfigImpl().copy( | ||
isDetailIncludedInLabel = false | ||
) | ||
|
||
check( | ||
"scope", | ||
""" | ||
|object A { | ||
| Lis@@ | ||
|}""".stripMargin, | ||
"""|List | ||
|List - java.awt | ||
|List - java.util | ||
|JList - javax.swing | ||
|ListUI - javax.swing.plaf | ||
|""".stripMargin, | ||
compat = Map( | ||
"2.13" -> | ||
"""|List | ||
|LazyList | ||
|List - java.awt | ||
|List - java.util | ||
|JList - javax.swing | ||
|""".stripMargin, | ||
"3" -> | ||
"""|List | ||
|List - java.awt | ||
|List - java.util | ||
|List - scala.collection.immutable | ||
|List[A](elems: A*): CC[A] | ||
|""".stripMargin | ||
), | ||
includeDetail = false, | ||
topLines = Some(5) | ||
) | ||
|
||
check( | ||
"member", | ||
""" | ||
|object A { | ||
| List.emp@@ | ||
|}""".stripMargin, | ||
""" | ||
|empty | ||
|""".stripMargin, | ||
includeDetail = false | ||
) | ||
|
||
check( | ||
"extension", | ||
""" | ||
|object A { | ||
| "".stripSu@@ | ||
|}""".stripMargin, | ||
"""|stripSuffix | ||
|""".stripMargin, | ||
includeDetail = false | ||
) | ||
|
||
check( | ||
"tparam", | ||
""" | ||
|class Foo[A] { | ||
| def identity[B >: A](a: B): B = a | ||
|} | ||
|object Foo { | ||
| new Foo[Int].ident@@ | ||
|}""".stripMargin, | ||
"""|identity | ||
|""".stripMargin, | ||
includeDetail = false | ||
) | ||
|
||
check( | ||
"tparam1", | ||
""" | ||
|class Foo[A] { | ||
| def identity(a: A): A = a | ||
|} | ||
|object Foo { | ||
| new Foo[Int].ident@@ | ||
|}""".stripMargin, | ||
"""|identity | ||
|""".stripMargin, | ||
includeDetail = false | ||
) | ||
|
||
check( | ||
"tparam2", | ||
""" | ||
|object A { | ||
| Map.empty[Int, String].getOrEl@@ | ||
|} | ||
|""".stripMargin, | ||
"""|getOrElse | ||
|""".stripMargin, | ||
includeDetail = false | ||
) | ||
|
||
check( | ||
"pkg", | ||
""" | ||
|import scala.collection.conc@@ | ||
|""".stripMargin, | ||
"""|concurrent | ||
|""".stripMargin, | ||
includeDetail = false | ||
) | ||
} |