File tree 1 file changed +15
-0
lines changed
Simperium/src/main/java/name/fraser/neil/plaintext
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1429,7 +1429,22 @@ public int diff_levenshtein(LinkedList<Diff> diffs) {
1429
1429
*/
1430
1430
public String diff_toDelta (LinkedList <Diff > diffs ) {
1431
1431
StringBuilder text = new StringBuilder ();
1432
+ char lastEnd = 0 ;
1433
+ boolean isFirst = true ;
1432
1434
for (Diff aDiff : diffs ) {
1435
+ char thisTop = aDiff .text .charAt (0 );
1436
+ char thisEnd = aDiff .text .charAt (aDiff .text .length () - 1 );
1437
+ if (Character .isHighSurrogate (thisEnd )) {
1438
+ aDiff .text = aDiff .text .substring (0 , aDiff .text .length () - 1 );
1439
+ }
1440
+ if (! isFirst && Character .isHighSurrogate (lastEnd ) && Character .isLowSurrogate (thisTop )) {
1441
+ aDiff .text = lastEnd + aDiff .text ;
1442
+ }
1443
+ isFirst = false ;
1444
+ lastEnd = thisEnd ;
1445
+ if ( aDiff .text .isEmpty () ) {
1446
+ continue ;
1447
+ }
1433
1448
switch (aDiff .operation ) {
1434
1449
case INSERT :
1435
1450
try {
You can’t perform that action at this time.
0 commit comments