@@ -941,9 +941,12 @@ pub fn diffCleanupSemanticLossless(
941941 equality_1 .items .len = equality_1 .items .len - common_offset ;
942942
943943 // edit.items.len = edit.items.len - common_offset;
944+ const not_common = try allocator .dupe (u8 , edit .items [0 .. edit .items .len - common_offset ]);
945+ defer allocator .free (not_common );
946+
944947 edit .items .len = 0 ;
945948 try edit .appendSlice (allocator , common_string );
946- try edit .appendSlice (allocator , common_string );
949+ try edit .appendSlice (allocator , not_common );
947950
948951 try equality_2 .insertSlice (allocator , 0 , common_string );
949952 }
@@ -1041,10 +1044,10 @@ fn diffCleanupSemanticScore(one: []const u8, two: []const u8) usize {
10411044 const lineBreak2 = whitespace2 and std .ascii .isControl (char2 );
10421045 const blankLine1 = lineBreak1 and
10431046 // BLANKLINEEND.IsMatch(one);
1044- (std .mem .endsWith (u8 , one , "\n " ) or std .mem .endsWith (u8 , one , "\r \n " ));
1047+ (std .mem .endsWith (u8 , one , "\n\n " ) or std .mem .endsWith (u8 , one , "\n \r \n " ));
10451048 const blankLine2 = lineBreak2 and
10461049 // BLANKLINESTART.IsMatch(two);
1047- (std .mem .startsWith (u8 , two , "\n " ) or std .mem .startsWith (u8 , two , "\r \n " ));
1050+ (std .mem .startsWith (u8 , two , "\n\n " ) or std .mem .startsWith (u8 , two , "\r \n\n " ) or std . mem . startsWith ( u8 , two , " \n \r \n " ) or std . mem . startsWith ( u8 , two , " \r \n \r \n " ));
10481051
10491052 if (blankLine1 or blankLine2 ) {
10501053 // Five points for blank lines.
@@ -1067,7 +1070,13 @@ fn diffCleanupSemanticScore(one: []const u8, two: []const u8) usize {
10671070
10681071// Define some regex patterns for matching boundaries.
10691072// private Regex BLANKLINEEND = new Regex("\\n\\r?\\n\\Z");
1073+ // \n\n
1074+ // \n\r\n
10701075// private Regex BLANKLINESTART = new Regex("\\A\\r?\\n\\r?\\n");
1076+ // \n\n
1077+ // \r\n\n
1078+ // \n\r\n
1079+ // \r\n\r\n
10711080
10721081/// Reduce the number of edits by eliminating operationally trivial
10731082/// equalities.
0 commit comments