Skip to content

Commit

Permalink
fix: don't add suffix if brackets already present
Browse files Browse the repository at this point in the history
[Cherry-picked b4b1541]
  • Loading branch information
kasiaMarek authored and WojciechMazur committed Aug 27, 2024
1 parent fb83702 commit fe42316
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ class Completions(
*/
case (fun) :: (appl: GenericApply) :: _ if appl.fun == fun =>
false
/* In case of `T@@[]` we should not add snippets.
*/
case tpe :: (appl: AppliedTypeTree) :: _ if appl.tpt == tpe =>
false
case _ :: (withcursor @ Select(fun, name)) :: (appl: GenericApply) :: _
if appl.fun == withcursor && name.decoded == Cursor.value =>
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,3 +451,34 @@ class CompletionSnippetSuite extends BaseCompletionSuite:
""".stripMargin,
filter = _.contains("bar: Int")
)

@Test def `brackets-already-present` =
check(
"""|package a
|case class AAA[T]()
|object O {
| val l: AA@@[Int] = ???
|}
|""".stripMargin,
"""|AAA a
|ArrowAssoc scala.Predef
|""".stripMargin,
)

@Test def `brackets-already-present-edit` =
checkEdit(
"""|package a
|case class AAA[T]()
|object O {
| val l: AA@@[Int] = ???
|}
|""".stripMargin,
"""|package a
|case class AAA[T]()
|object O {
| val l: AAA[Int] = ???
|}
|""".stripMargin,
assertSingleItem = false,
)

0 comments on commit fe42316

Please sign in to comment.