Skip to content

Commit

Permalink
ScalafmtConfig: fix withoutRewrites trailingCommas
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Oct 3, 2023
1 parent 3adc085 commit 84c9f26
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ case class RewriteSettings(
allowInfixPlaceholderArg: Boolean = true,
neverInfix: Pattern = Pattern.neverInfix
) {
def withoutRewrites: RewriteSettings =
copy(rules = Nil, trailingCommas = trailingCommas.withoutRewrites)

def rewriteFactoryRules: Seq[RewriteFactory] =
rules.collect { case x: RewriteFactory => x }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ case class ScalafmtConfig(
// used in ScalafmtReflectConfig
def withoutRewrites: ScalafmtConfig = copy(
trailingCommas = None,
rewrite = RewriteSettings.default
rewrite = rewrite.withoutRewrites
)

lazy val forceNewlineBeforeDocstring: Boolean =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import metaconfig._
case class TrailingCommas(
allowFolding: Boolean = true,
style: TrailingCommas.Style = TrailingCommas.never
)
) {
def withoutRewrites: TrailingCommas = copy(style = TrailingCommas.keep)
}

object TrailingCommas {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ScalafmtConfigTest extends FunSuite {
.get
assert(config1.hasRewrites)
val config2 = config1.withoutRewrites
assert(config2.hasRewrites) // XXX: this is incorrect
assert(!config2.hasRewrites)
}

test("hasRewriteRules-and-withoutRewriteRules docstrings") {
Expand Down

0 comments on commit 84c9f26

Please sign in to comment.