Skip to content

Commit

Permalink
bugfix: don't show arg completions for infix
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Jul 20, 2023
1 parent b334da8 commit a073513
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,18 @@ trait Completions { this: MetalsGlobal =>
ident: Ident,
apply: Apply
): CompletionPosition = {
def isInfix(apply: Apply, text: String) =
apply.fun match {
case Select(New(_), _) => false
case Select(_, name) if name.decoded == "apply" => false
case Select(This(_), _) => false
// is a select statement without a dot `qual.name`
case Select(qual, _) => {
val pos = qual.pos.end
pos < text.length() && text(pos) != '.'
}
case _ => false
}
if (hasLeadingBrace(ident, text)) {
if (isCasePrefix(ident.name)) {
val moveToNewLine = ident.pos.line == apply.pos.line
Expand All @@ -473,7 +485,9 @@ trait Completions { this: MetalsGlobal =>
NoneCompletion
}
} else {
ArgCompletion(ident, apply, pos, text, completions)
if (!isInfix(apply, text)) {
ArgCompletion(ident, apply, pos, text, completions)
} else NoneCompletion
}
}

Expand Down
11 changes: 0 additions & 11 deletions tests/cross/src/test/scala/tests/pc/CompletionArgSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -501,18 +501,7 @@ class CompletionArgSuite extends BaseCompletionSuite {
|}
|""".stripMargin,
"""|x: Int
|x = : Byte
|x = : Char
|x = : Double
|x = : Float
|x = : Int
|x = : Long
|x = : Short
|x = x : Int
|""".stripMargin,
compat = Map(
"3" -> "x: Int"
),
)

check(
Expand Down

0 comments on commit a073513

Please sign in to comment.