Selaa lähdekoodia

Oopsie. One index is enough.

Piotrek Koszuliński 9 vuotta sitten
vanhempi
commit
5c6b2108df
1 muutettua tiedostoa jossa 7 lisäystä ja 10 poistoa
  1. 7 10
      packages/ckeditor5-utils/src/batchify.js

+ 7 - 10
packages/ckeditor5-utils/src/batchify.js

@@ -31,31 +31,28 @@
  */
 export default function batchify( diff, output ) {
 	const batch = [];
-	let left = 0;
-	let right = 0;
+	let index = 0;
 	let lastOperation;
 
 	diff.forEach( change => {
 		if ( change == 'EQUAL' ) {
 			pushLast();
 
-			left++;
-			right++;
+			index++;
 		} else if ( change == 'INSERT' ) {
 			if ( isContinuationOf( 'INSERT' ) ) {
-				lastOperation.values.push( output[ right ] );
+				lastOperation.values.push( output[ index ] );
 			} else {
 				pushLast();
 
 				lastOperation = {
 					type: 'INSERT',
-					index: left,
-					values: [ output[ right ] ]
+					index: index,
+					values: [ output[ index ] ]
 				};
 			}
 
-			left++;
-			right++;
+			index++;
 		} else /* if ( change == 'DELETE' ) */ {
 			if ( isContinuationOf( 'DELETE' ) ) {
 				lastOperation.howMany++;
@@ -64,7 +61,7 @@ export default function batchify( diff, output ) {
 
 				lastOperation = {
 					type: 'DELETE',
-					index: left,
+					index: index,
 					howMany: 1
 				};
 			}