Skip to content

Commit

Permalink
bugfix: When determining indent first check for pipe
Browse files Browse the repository at this point in the history
Fixes #6798
  • Loading branch information
tgodzik committed Oct 30, 2024
1 parent 50af2c8 commit bcba920
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ case class MultilineString(userConfig: () => UserConfiguration)
val index =
if (lineToCheck.contains("\"\"\"|")) {
lineToCheck.indexOf('"') + 3
} else if (lineToCheck.contains("|")) {
lineToCheck.indexOf('|')
} else if (lineToCheck.contains("\"\"\"")) {
lineToCheck.indexOf('"') + 2
} else lineToCheck.indexOf('|')
} else 0
space * index
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,19 @@ class MultilineStringRangeFormattingWhenPastingSuite
|}""".stripMargin,
)

check(
"i6798",
s"""|val x =
| s'''|Hello
| |Good@@'''.stripMargin
|}""".stripMargin,
"bye",
s"""|val x =
| s'''|Hello
| |Goodbye'''.stripMargin
|}""".stripMargin,
)

def check(
name: TestOptions,
testCase: String,
Expand All @@ -358,7 +371,7 @@ class MultilineStringRangeFormattingWhenPastingSuite
s"""/metals.json
|{"a":{}}
|/a/src/main/scala/a/Main.scala
""".stripMargin + base
|""".stripMargin + base
)
_ <- server.didOpen("a/src/main/scala/a/Main.scala")
_ <- server.rangeFormatting(
Expand Down

0 comments on commit bcba920

Please sign in to comment.