From 705b4cf96b8597ecbef3a69752a09c9535973cf4 Mon Sep 17 00:00:00 2001 From: XuJiang Date: Wed, 9 Oct 2024 12:09:11 -0400 Subject: [PATCH] Update the rule of inlineDiffByWord Only if one word has space, show inlineDiffByWord. --- .../java/org/junit/platform/console/tasks/DiffPrinter.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/junit-platform-console/src/main/java/org/junit/platform/console/tasks/DiffPrinter.java b/junit-platform-console/src/main/java/org/junit/platform/console/tasks/DiffPrinter.java index 05639c27f949..5ec2a200672e 100644 --- a/junit-platform-console/src/main/java/org/junit/platform/console/tasks/DiffPrinter.java +++ b/junit-platform-console/src/main/java/org/junit/platform/console/tasks/DiffPrinter.java @@ -23,7 +23,11 @@ class DiffPrinter { //print the difference of two print to out static void printDiff(PrintWriter out, String expected, String actual) { - DiffRowGenerator generator = DiffRowGenerator.create().showInlineDiffs(true).inlineDiffByWord(true).oldTag( + boolean inlineDiffByWordFlag = false; + if(expected.contains(" ") || actual.contains(" ")){ + inlineDiffByWordFlag = true; + } + DiffRowGenerator generator = DiffRowGenerator.create().showInlineDiffs(true).inlineDiffByWord(inlineDiffByWordFlag).oldTag( f -> "~~").newTag(f -> "**").build(); List rows = generator.generateDiffRows(Arrays.asList(expected), Arrays.asList(actual)); out.println();