@@ -12,13 +12,13 @@ object DiffResultPrinter {
12
12
case dr : DiffResultString => s " ${dr.diffs.map(ds => showIndented(ds, indent)).mkString(" \n " )}"
13
13
case dr : DiffResultStringLine => mergeChunks(dr.diffs).map(ds => showIndented(ds, indent)).mkString
14
14
case dr : DiffResultStringWord => mergeChunks(dr.diffs).map(ds => showIndented(ds, indent)).mkString
15
- case dr : DiffResultChunk => arrowColor(" [" ) + showChange(s " ${dr.left}" , s " ${dr.right}" ) + arrowColor(" ]" )
16
- case dr : DiffResultValue [_] => showChange(s " ${dr.left}" , s " ${dr.right}" )
17
- case dr : IdenticalValue [_] => defaultColor(s " ${dr.value}" )
18
- case dr : DiffResultMissing [_] => missingColor(s " ${dr.value}" )
19
- case dr : DiffResultMissingChunk => missingColor(s " [ ${dr.value}] " )
20
- case dr : DiffResultAdditional [_] => additionalColor(s " ${dr.value}" )
21
- case dr : DiffResultAdditionalChunk => additionalColor(s " [ ${dr.value}] " )
15
+ case dr : DiffResultChunk => arrowColor(" [" ) + showChange(s " ${dr.left}" , s " ${dr.right}" , indent ) + arrowColor(" ]" )
16
+ case dr : DiffResultValue [_] => showChange(s " ${dr.left}" , s " ${dr.right}" , indent )
17
+ case dr : IdenticalValue [_] => defaultColor(s " ${dr.value}" , indent )
18
+ case dr : DiffResultMissing [_] => missingColor(s " ${dr.value}" , indent )
19
+ case dr : DiffResultMissingChunk => missingColor(s " [ ${dr.value}] " , indent )
20
+ case dr : DiffResultAdditional [_] => additionalColor(s " ${dr.value}" , indent )
21
+ case dr : DiffResultAdditionalChunk => additionalColor(s " [ ${dr.value}] " , indent )
22
22
}
23
23
}
24
24
@@ -89,12 +89,14 @@ object DiffResultPrinter {
89
89
}
90
90
}
91
91
92
- private def leftColor (s : String )(implicit c : ShowConfig ): String = c.left(s)
93
- private def missingColor (s : String )(implicit c : ShowConfig ): String = c.missing(s)
94
- private def additionalColor (s : String )(implicit c : ShowConfig ): String = c.additional(s)
95
- private def rightColor (s : String )(implicit c : ShowConfig ): String = c.right(s)
96
- private def defaultColor (s : String )(implicit c : ShowConfig ): String = c.default(s)
92
+ private def missingColor (s : String , indent : Int )(implicit c : ShowConfig ): String = withColor(s, c.missing, indent)
93
+ private def additionalColor (s : String , indent : Int )(implicit c : ShowConfig ): String = withColor(s, c.additional, indent)
94
+ private def defaultColor (s : String , indent : Int = 0 )(implicit c : ShowConfig ): String = withColor(s, c.default, indent)
97
95
private def arrowColor (s : String )(implicit c : ShowConfig ): String = c.arrow(s)
98
- private def showChange (l : String , r : String )(implicit c : ShowConfig ): String =
99
- leftColor(l) + arrowColor(" -> " ) + rightColor(r)
96
+ private def showChange (l : String , r : String , indent : Int )(implicit c : ShowConfig ): String =
97
+ withColor(l, c.left, indent) + arrowColor(" -> " ) + withColor(r, c.right, indent)
98
+
99
+ private def withColor (value : String , color : String => String , indent : Int ): String = {
100
+ value.split(" \n " , - 1 ).map(color(_)).mkString(" \n " + " " .repeat(indent))
101
+ }
100
102
}
0 commit comments