From e31971af909462b9f1d3a6bbbb148268aea80f8c Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Mon, 27 Dec 2021 11:22:51 -0800 Subject: [PATCH] FormatWriter: fix indentation detection logic --- .../src/main/scala/org/scalafmt/internal/FormatWriter.scala | 2 +- scalafmt-tests/src/test/resources/unit/Comment.stat | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatWriter.scala b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatWriter.scala index 6b42ae4867..29f24dfbb8 100644 --- a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatWriter.scala +++ b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatWriter.scala @@ -640,7 +640,7 @@ class FormatWriter(formatOps: FormatOps) { protected final val breakBefore = curr.hasBreakBefore protected final val indent = if (breakBefore) prevState.indentation - else prevState.prev.indentation + else math.max(prevState.indentation, prevState.prev.indentation) // extra 1 is for "*" (in "/*" or " *") or "/" (in "//") protected final val maxLength = maxColumn - indent - extraIndent - 1 diff --git a/scalafmt-tests/src/test/resources/unit/Comment.stat b/scalafmt-tests/src/test/resources/unit/Comment.stat index 21ee6871df..69fc71aa84 100644 --- a/scalafmt-tests/src/test/resources/unit/Comment.stat +++ b/scalafmt-tests/src/test/resources/unit/Comment.stat @@ -665,7 +665,7 @@ object a { >>> object a { def foo( /* First 2 will not be taken into - * account */ + * account */ foo1: Int, foo2: String, /* Next 2 will not * be taken into account since * 'filterDoNotSellBy' is not set */