Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router: add NL split in select chain for src=keep #4021

Merged
merged 2 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1700,7 +1700,12 @@ class Router(formatOps: FormatOps) {

case _ if left.is[T.Comment] => Seq(Split(Space.orNL(t.noBreak), 0))

case Newlines.keep => Seq(Split(NoSplit.orNL(t.noBreak), 0))
case Newlines.keep =>
if (t.noBreak) Seq(
Split(NoSplit, 0),
Split(Newline, Constants.ExceedColumnPenalty * 3),
)
else Seq(Split(Newline, 0))

case Newlines.unfold =>
val nlCost = if (nlOnly) 0 else 1
Expand Down
20 changes: 10 additions & 10 deletions scalafmt-tests/src/test/resources/newlines/source_keep.stat
Original file line number Diff line number Diff line change
Expand Up @@ -945,9 +945,8 @@ object a {
}
>>>
object a {
(intercept[java.lang.IllegalStateException] {
in.readObject
}).getMessage should ===(
(intercept[java.lang.IllegalStateException] { in.readObject })
.getMessage should ===(
"Trying to deserialize a serialized ActorRef without an ActorSystem in scope." +
" Use 'akka.serialization.Serialization.currentSystem.withValue(system) { ... }'")
}
Expand Down Expand Up @@ -2073,9 +2072,8 @@ object a {
}
>>>
object a {
plugins(
service.pluginType
) += service.pluginName -> service
plugins(service.pluginType) += service
.pluginName -> service
}
<<< 8.7
maxColumn = 80
Expand Down Expand Up @@ -2803,7 +2801,10 @@ object a {
test("foo") {
a.b(c, d) shouldBe
E(Seq(F(1, "v1"), F(2, "v2")),
G(Some(Seq(h, i)), Some(Seq(j, k)), a.b, c.d, e.f.g, h.i.j)).foo
G(Some(Seq(h, i)),
Some(Seq(j, k)), a.b, c.d,
e.f.g, h.i.j))
.foo
}
}
<<< binpack call, oneline, with syntaxNL, single arg
Expand Down Expand Up @@ -3551,9 +3552,8 @@ pubSubMessage match {
case message: UploadMessage => {
val services = makeUploadServices()

UploadSubscriber(
services
).processEff(message)
UploadSubscriber(services)
.processEff(message)
}
case message: IngestionMessage => (
IngestionSubscriber.defaultServices
Expand Down
27 changes: 27 additions & 0 deletions scalafmt-tests/src/test/resources/scalajs/Apply.stat
Original file line number Diff line number Diff line change
Expand Up @@ -1045,3 +1045,30 @@ object a {
})(
OptimizerHints.empty, Unversioned)
}
<<< oneline with keep and select after
preset = default
maxColumn = 80
newlines.source = keep
binPack.preset = oneline
danglingParentheses.preset = false
newlines.configStyleCallSite.prefer = true
newlines.avoidForSimpleOverflow = [tooLong, punct, slc]
===
object a {
def createResetButton(): JQuery = {
jQuery("<input>", js.Dynamic.literal(
`type` = "button", value = "Reset"
)).click(() => reset())
}
}
>>>
object a {
def createResetButton(): JQuery = {
jQuery("<input>",
js.Dynamic.literal(
`type` = "button",
value = "Reset"
))
.click(() => reset())
}
}
Loading