Skip to content

Commit 73218a0

Browse files
committed
Columnator accepts multiline field2
1 parent 061a1a5 commit 73218a0

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

compiler/src/dotty/tools/dotc/config/CliCommand.scala

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,20 @@ trait CliCommand:
189189
val separator = " " * separation
190190
def formatField1(text: String): String = if text.length <= field1 then text.padLeft(field1) else EOL + "".padLeft(field1)
191191
def formatField2(text: String): String =
192-
if field2 == 0 || text.length <= field2 then text
193-
else
194-
text.lastIndexOf(" ", field2) match
195-
case -1 => text
196-
case i =>
197-
val (prefix, rest) = text.splitAt(i)
198-
s"${prefix}${EOL}${formatField1("")}${separator}${formatField2(rest.trim)}"
192+
def loopOverField2(fld: String): String =
193+
if field2 == 0 || fld.length <= field2 then fld
194+
else
195+
fld.lastIndexOf(" ", field2) match
196+
case -1 => fld
197+
case i =>
198+
val (prefix, rest) = fld.splitAt(i)
199+
s"${prefix}${EOL}${formatField1("")}${separator}${loopOverField2(rest.trim)}"
200+
def loopOverFields2(rest: List[String]): String =
201+
rest match
202+
case h :: t => loopOverField2(h.trim) + loopOverFields2(t)
203+
case Nil => ""
204+
loopOverFields2(text.split("\n").toList)
205+
end formatField2
199206
def format(first: String, second: String, index: Int, colorPicker: Int => String => Highlight) =
200207
sb.append(colorPicker(index)(formatField1(first)).show)
201208
.append(separator)

0 commit comments

Comments
 (0)