From e754a2d790e0cf5ab2c1480166a42cbb908add0f Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Tue, 4 Oct 2016 15:51:15 +0200 Subject: Change `typeDiff` to highlight changes less than 50% --- src/dotty/tools/dotc/printing/Formatting.scala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/dotty/tools/dotc/printing/Formatting.scala') diff --git a/src/dotty/tools/dotc/printing/Formatting.scala b/src/dotty/tools/dotc/printing/Formatting.scala index 76d2bdc18..719c23e84 100644 --- a/src/dotty/tools/dotc/printing/Formatting.scala +++ b/src/dotty/tools/dotc/printing/Formatting.scala @@ -242,17 +242,17 @@ object Formatting { * correct `Context` for printing should also be passed when calling the * method. * - * @return the (found, expected) with coloring to highlight the difference + * @return the (found, expected, changePercentage) with coloring to + * highlight the difference */ def typeDiff(found: Type, expected: Type)(implicit ctx: Context): (String, String) = { val fnd = wrapNonSensical(found, found.show) val exp = wrapNonSensical(expected, expected.show) - (found, expected) match { - case (_: RefinedType, _: RefinedType) if ctx.settings.color.value != "never" => - DiffUtil.mkColoredTypeDiff(fnd, exp) - case _ => - (hl"$fnd", hl"$exp") + DiffUtil.mkColoredTypeDiff(fnd, exp) match { + case _ if ctx.settings.color.value == "never" => (fnd, exp) + case (fnd, exp, change) if change < 0.5 => (fnd, exp) + case _ => (fnd, exp) } } } -- cgit v1.2.3