@@ -6,7 +6,7 @@ import 'dart:math';
66
77/// Generates a "focused" unified diff, showing only the changed lines
88/// plus a few lines of context around them.
9- String generateFocusedDiff (
9+ List < String > generateFocusedDiff (
1010 String expected,
1111 String actual, {
1212 int contextLines = 3 ,
@@ -30,7 +30,7 @@ String generateFocusedDiff(
3030 }
3131
3232 if (indicesToInclude.isEmpty) {
33- return 'No differences found.' ;
33+ return [ 'No differences found.' ] ;
3434 }
3535
3636 int lastIncludedIndex = - 1 ;
@@ -45,25 +45,28 @@ String generateFocusedDiff(
4545 lastIncludedIndex = i;
4646 }
4747
48- return outputLines. join ( ' \n ' ) ;
48+ return outputLines;
4949}
5050
5151/// Generates a "full" unified diff, showing every line from the comparison.
52- String generateFullDiff (String expected, String actual) {
52+ List < String > generateFullDiff (String expected, String actual) {
5353 var diffResults = _createDiff (expected, actual);
54- return diffResults.map (_formatLine).join ( ' \n ' );
54+ return diffResults.map (_formatLine).toList ( );
5555}
5656
5757void printPrettyDiff (String expected, String actual, {int context = 3 }) {
5858 var full = generateFullDiff (expected, actual);
5959 var short = generateFocusedDiff (expected, actual);
60- print ('-------- Short diff --------' );
61- print (short);
60+
61+ if (full.length * 0.3 >= short.length) {
62+ print ('-------- Short diff --------' );
63+ print (short.join ('/n' ));
64+ }
6265 print ('-------- Full diff ---------' );
63- print (full);
66+ print (full. join ( '/n' ) );
6467 print ('---------- Actual ----------' );
6568 print (actual.trimRight ());
66- print ('------------------------' );
69+ print ('---------------------------- ' );
6770}
6871
6972/// Backtracks through the LCS table to build the list of diff results.
0 commit comments