Skip to content

Commit

Permalink
FormatTokens: fix getLastExceptParen, incl comment
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Nov 20, 2024
1 parent f0237c8 commit 96e3b05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ class FormatTokens(leftTok2tok: Map[TokenHash, Int])(val arr: Array[FT])

def getLastExceptParen(tree: Tree): FT = {
val tokens = tree.tokens
val last = getLastNonTrivial(tokens, tree)
getClosingIfWithinParens(last)(getHead(tokens, tree)).getOrElse(last)
val last = getLast(tokens, tree)
getClosingIfWithinParens(prevNonComment(last))(getHead(tokens, tree))
.getOrElse(last)
}

final def findTokenWith[A](ft: FT, iter: FT => FT)(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7925,11 +7925,12 @@ object a:
case d if e => f
// comment
>>>
Idempotency violated
=> Diff (- obtained, + expected)
f
- // comment
+ // comment
object a:
b.c
.match
case d if e =>
f
// comment
<<< match without dot, trailing case comment
object a:
b.c match
Expand Down

0 comments on commit 96e3b05

Please sign in to comment.