Skip to content

Commit

Permalink
fix StringFormatToInterpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Jan 8, 2024
1 parent 0396a76 commit 32e43b3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ class StringFormatToInterpolationTest {
"%s \\ ".format("x")

" %s \" ".format("x")

"\n %s aaa \n %s bbb".format(1, 2)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ class StringFormatToInterpolationTest {
"%s \\ ".format("x")

" %s \" ".format("x")

s"\n ${1} aaa \n ${2} bbb"
}
2 changes: 1 addition & 1 deletion rules/src/main/scala/fix/StringFormatToInterpolation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class StringFormatToInterpolation extends SyntacticRule("StringFormatToInterpola
new java.lang.StringBuilder("s\"")
}
str.split("%s", -1).zipWithIndex.foreach { case (s, i) =>
buf.append(s)
buf.append(s.replace("\n", "\\n"))
if (i < args.length) {
buf.append("${")
buf.append(args(i))
Expand Down

0 comments on commit 32e43b3

Please sign in to comment.