Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cleanupSemantic.js 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.cleanupSemantic =
  6. exports.DIFF_INSERT =
  7. exports.DIFF_DELETE =
  8. exports.DIFF_EQUAL =
  9. exports.Diff =
  10. void 0;
  11. function _defineProperty(obj, key, value) {
  12. if (key in obj) {
  13. Object.defineProperty(obj, key, {
  14. value: value,
  15. enumerable: true,
  16. configurable: true,
  17. writable: true
  18. });
  19. } else {
  20. obj[key] = value;
  21. }
  22. return obj;
  23. }
  24. /**
  25. * Diff Match and Patch
  26. * Copyright 2018 The diff-match-patch Authors.
  27. * https://github.com/google/diff-match-patch
  28. *
  29. * Licensed under the Apache License, Version 2.0 (the "License");
  30. * you may not use this file except in compliance with the License.
  31. * You may obtain a copy of the License at
  32. *
  33. * http://www.apache.org/licenses/LICENSE-2.0
  34. *
  35. * Unless required by applicable law or agreed to in writing, software
  36. * distributed under the License is distributed on an "AS IS" BASIS,
  37. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  38. * See the License for the specific language governing permissions and
  39. * limitations under the License.
  40. */
  41. /**
  42. * @fileoverview Computes the difference between two texts to create a patch.
  43. * Applies the patch onto another text, allowing for errors.
  44. * @author fraser@google.com (Neil Fraser)
  45. */
  46. /**
  47. * CHANGES by pedrottimark to diff_match_patch_uncompressed.ts file:
  48. *
  49. * 1. Delete anything not needed to use diff_cleanupSemantic method
  50. * 2. Convert from prototype properties to var declarations
  51. * 3. Convert Diff to class from constructor and prototype
  52. * 4. Add type annotations for arguments and return values
  53. * 5. Add exports
  54. */
  55. /**
  56. * The data structure representing a diff is an array of tuples:
  57. * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
  58. * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
  59. */
  60. var DIFF_DELETE = -1;
  61. exports.DIFF_DELETE = DIFF_DELETE;
  62. var DIFF_INSERT = 1;
  63. exports.DIFF_INSERT = DIFF_INSERT;
  64. var DIFF_EQUAL = 0;
  65. /**
  66. * Class representing one diff tuple.
  67. * Attempts to look like a two-element array (which is what this used to be).
  68. * @param {number} op Operation, one of: DIFF_DELETE, DIFF_INSERT, DIFF_EQUAL.
  69. * @param {string} text Text to be deleted, inserted, or retained.
  70. * @constructor
  71. */
  72. exports.DIFF_EQUAL = DIFF_EQUAL;
  73. class Diff {
  74. constructor(op, text) {
  75. _defineProperty(this, 0, void 0);
  76. _defineProperty(this, 1, void 0);
  77. this[0] = op;
  78. this[1] = text;
  79. }
  80. }
  81. /**
  82. * Determine the common prefix of two strings.
  83. * @param {string} text1 First string.
  84. * @param {string} text2 Second string.
  85. * @return {number} The number of characters common to the start of each
  86. * string.
  87. */
  88. exports.Diff = Diff;
  89. var diff_commonPrefix = function (text1, text2) {
  90. // Quick check for common null cases.
  91. if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) {
  92. return 0;
  93. } // Binary search.
  94. // Performance analysis: https://neil.fraser.name/news/2007/10/09/
  95. var pointermin = 0;
  96. var pointermax = Math.min(text1.length, text2.length);
  97. var pointermid = pointermax;
  98. var pointerstart = 0;
  99. while (pointermin < pointermid) {
  100. if (
  101. text1.substring(pointerstart, pointermid) ==
  102. text2.substring(pointerstart, pointermid)
  103. ) {
  104. pointermin = pointermid;
  105. pointerstart = pointermin;
  106. } else {
  107. pointermax = pointermid;
  108. }
  109. pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
  110. }
  111. return pointermid;
  112. };
  113. /**
  114. * Determine the common suffix of two strings.
  115. * @param {string} text1 First string.
  116. * @param {string} text2 Second string.
  117. * @return {number} The number of characters common to the end of each string.
  118. */
  119. var diff_commonSuffix = function (text1, text2) {
  120. // Quick check for common null cases.
  121. if (
  122. !text1 ||
  123. !text2 ||
  124. text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1)
  125. ) {
  126. return 0;
  127. } // Binary search.
  128. // Performance analysis: https://neil.fraser.name/news/2007/10/09/
  129. var pointermin = 0;
  130. var pointermax = Math.min(text1.length, text2.length);
  131. var pointermid = pointermax;
  132. var pointerend = 0;
  133. while (pointermin < pointermid) {
  134. if (
  135. text1.substring(text1.length - pointermid, text1.length - pointerend) ==
  136. text2.substring(text2.length - pointermid, text2.length - pointerend)
  137. ) {
  138. pointermin = pointermid;
  139. pointerend = pointermin;
  140. } else {
  141. pointermax = pointermid;
  142. }
  143. pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
  144. }
  145. return pointermid;
  146. };
  147. /**
  148. * Determine if the suffix of one string is the prefix of another.
  149. * @param {string} text1 First string.
  150. * @param {string} text2 Second string.
  151. * @return {number} The number of characters common to the end of the first
  152. * string and the start of the second string.
  153. * @private
  154. */
  155. var diff_commonOverlap_ = function (text1, text2) {
  156. // Cache the text lengths to prevent multiple calls.
  157. var text1_length = text1.length;
  158. var text2_length = text2.length; // Eliminate the null case.
  159. if (text1_length == 0 || text2_length == 0) {
  160. return 0;
  161. } // Truncate the longer string.
  162. if (text1_length > text2_length) {
  163. text1 = text1.substring(text1_length - text2_length);
  164. } else if (text1_length < text2_length) {
  165. text2 = text2.substring(0, text1_length);
  166. }
  167. var text_length = Math.min(text1_length, text2_length); // Quick check for the worst case.
  168. if (text1 == text2) {
  169. return text_length;
  170. } // Start by looking for a single character match
  171. // and increase length until no match is found.
  172. // Performance analysis: https://neil.fraser.name/news/2010/11/04/
  173. var best = 0;
  174. var length = 1;
  175. while (true) {
  176. var pattern = text1.substring(text_length - length);
  177. var found = text2.indexOf(pattern);
  178. if (found == -1) {
  179. return best;
  180. }
  181. length += found;
  182. if (
  183. found == 0 ||
  184. text1.substring(text_length - length) == text2.substring(0, length)
  185. ) {
  186. best = length;
  187. length++;
  188. }
  189. }
  190. };
  191. /**
  192. * Reduce the number of edits by eliminating semantically trivial equalities.
  193. * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
  194. */
  195. var diff_cleanupSemantic = function (diffs) {
  196. var changes = false;
  197. var equalities = []; // Stack of indices where equalities are found.
  198. var equalitiesLength = 0; // Keeping our own length var is faster in JS.
  199. /** @type {?string} */
  200. var lastEquality = null; // Always equal to diffs[equalities[equalitiesLength - 1]][1]
  201. var pointer = 0; // Index of current position.
  202. // Number of characters that changed prior to the equality.
  203. var length_insertions1 = 0;
  204. var length_deletions1 = 0; // Number of characters that changed after the equality.
  205. var length_insertions2 = 0;
  206. var length_deletions2 = 0;
  207. while (pointer < diffs.length) {
  208. if (diffs[pointer][0] == DIFF_EQUAL) {
  209. // Equality found.
  210. equalities[equalitiesLength++] = pointer;
  211. length_insertions1 = length_insertions2;
  212. length_deletions1 = length_deletions2;
  213. length_insertions2 = 0;
  214. length_deletions2 = 0;
  215. lastEquality = diffs[pointer][1];
  216. } else {
  217. // An insertion or deletion.
  218. if (diffs[pointer][0] == DIFF_INSERT) {
  219. length_insertions2 += diffs[pointer][1].length;
  220. } else {
  221. length_deletions2 += diffs[pointer][1].length;
  222. } // Eliminate an equality that is smaller or equal to the edits on both
  223. // sides of it.
  224. if (
  225. lastEquality &&
  226. lastEquality.length <=
  227. Math.max(length_insertions1, length_deletions1) &&
  228. lastEquality.length <= Math.max(length_insertions2, length_deletions2)
  229. ) {
  230. // Duplicate record.
  231. diffs.splice(
  232. equalities[equalitiesLength - 1],
  233. 0,
  234. new Diff(DIFF_DELETE, lastEquality)
  235. ); // Change second copy to insert.
  236. diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT; // Throw away the equality we just deleted.
  237. equalitiesLength--; // Throw away the previous equality (it needs to be reevaluated).
  238. equalitiesLength--;
  239. pointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1;
  240. length_insertions1 = 0; // Reset the counters.
  241. length_deletions1 = 0;
  242. length_insertions2 = 0;
  243. length_deletions2 = 0;
  244. lastEquality = null;
  245. changes = true;
  246. }
  247. }
  248. pointer++;
  249. } // Normalize the diff.
  250. if (changes) {
  251. diff_cleanupMerge(diffs);
  252. }
  253. diff_cleanupSemanticLossless(diffs); // Find any overlaps between deletions and insertions.
  254. // e.g: <del>abcxxx</del><ins>xxxdef</ins>
  255. // -> <del>abc</del>xxx<ins>def</ins>
  256. // e.g: <del>xxxabc</del><ins>defxxx</ins>
  257. // -> <ins>def</ins>xxx<del>abc</del>
  258. // Only extract an overlap if it is as big as the edit ahead or behind it.
  259. pointer = 1;
  260. while (pointer < diffs.length) {
  261. if (
  262. diffs[pointer - 1][0] == DIFF_DELETE &&
  263. diffs[pointer][0] == DIFF_INSERT
  264. ) {
  265. var deletion = diffs[pointer - 1][1];
  266. var insertion = diffs[pointer][1];
  267. var overlap_length1 = diff_commonOverlap_(deletion, insertion);
  268. var overlap_length2 = diff_commonOverlap_(insertion, deletion);
  269. if (overlap_length1 >= overlap_length2) {
  270. if (
  271. overlap_length1 >= deletion.length / 2 ||
  272. overlap_length1 >= insertion.length / 2
  273. ) {
  274. // Overlap found. Insert an equality and trim the surrounding edits.
  275. diffs.splice(
  276. pointer,
  277. 0,
  278. new Diff(DIFF_EQUAL, insertion.substring(0, overlap_length1))
  279. );
  280. diffs[pointer - 1][1] = deletion.substring(
  281. 0,
  282. deletion.length - overlap_length1
  283. );
  284. diffs[pointer + 1][1] = insertion.substring(overlap_length1);
  285. pointer++;
  286. }
  287. } else {
  288. if (
  289. overlap_length2 >= deletion.length / 2 ||
  290. overlap_length2 >= insertion.length / 2
  291. ) {
  292. // Reverse overlap found.
  293. // Insert an equality and swap and trim the surrounding edits.
  294. diffs.splice(
  295. pointer,
  296. 0,
  297. new Diff(DIFF_EQUAL, deletion.substring(0, overlap_length2))
  298. );
  299. diffs[pointer - 1][0] = DIFF_INSERT;
  300. diffs[pointer - 1][1] = insertion.substring(
  301. 0,
  302. insertion.length - overlap_length2
  303. );
  304. diffs[pointer + 1][0] = DIFF_DELETE;
  305. diffs[pointer + 1][1] = deletion.substring(overlap_length2);
  306. pointer++;
  307. }
  308. }
  309. pointer++;
  310. }
  311. pointer++;
  312. }
  313. };
  314. /**
  315. * Look for single edits surrounded on both sides by equalities
  316. * which can be shifted sideways to align the edit to a word boundary.
  317. * e.g: The c<ins>at c</ins>ame. -> The <ins>cat </ins>came.
  318. * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
  319. */
  320. exports.cleanupSemantic = diff_cleanupSemantic;
  321. var diff_cleanupSemanticLossless = function (diffs) {
  322. /**
  323. * Given two strings, compute a score representing whether the internal
  324. * boundary falls on logical boundaries.
  325. * Scores range from 6 (best) to 0 (worst).
  326. * Closure, but does not reference any external variables.
  327. * @param {string} one First string.
  328. * @param {string} two Second string.
  329. * @return {number} The score.
  330. * @private
  331. */
  332. function diff_cleanupSemanticScore_(one, two) {
  333. if (!one || !two) {
  334. // Edges are the best.
  335. return 6;
  336. } // Each port of this function behaves slightly differently due to
  337. // subtle differences in each language's definition of things like
  338. // 'whitespace'. Since this function's purpose is largely cosmetic,
  339. // the choice has been made to use each language's native features
  340. // rather than force total conformity.
  341. var char1 = one.charAt(one.length - 1);
  342. var char2 = two.charAt(0);
  343. var nonAlphaNumeric1 = char1.match(nonAlphaNumericRegex_);
  344. var nonAlphaNumeric2 = char2.match(nonAlphaNumericRegex_);
  345. var whitespace1 = nonAlphaNumeric1 && char1.match(whitespaceRegex_);
  346. var whitespace2 = nonAlphaNumeric2 && char2.match(whitespaceRegex_);
  347. var lineBreak1 = whitespace1 && char1.match(linebreakRegex_);
  348. var lineBreak2 = whitespace2 && char2.match(linebreakRegex_);
  349. var blankLine1 = lineBreak1 && one.match(blanklineEndRegex_);
  350. var blankLine2 = lineBreak2 && two.match(blanklineStartRegex_);
  351. if (blankLine1 || blankLine2) {
  352. // Five points for blank lines.
  353. return 5;
  354. } else if (lineBreak1 || lineBreak2) {
  355. // Four points for line breaks.
  356. return 4;
  357. } else if (nonAlphaNumeric1 && !whitespace1 && whitespace2) {
  358. // Three points for end of sentences.
  359. return 3;
  360. } else if (whitespace1 || whitespace2) {
  361. // Two points for whitespace.
  362. return 2;
  363. } else if (nonAlphaNumeric1 || nonAlphaNumeric2) {
  364. // One point for non-alphanumeric.
  365. return 1;
  366. }
  367. return 0;
  368. }
  369. var pointer = 1; // Intentionally ignore the first and last element (don't need checking).
  370. while (pointer < diffs.length - 1) {
  371. if (
  372. diffs[pointer - 1][0] == DIFF_EQUAL &&
  373. diffs[pointer + 1][0] == DIFF_EQUAL
  374. ) {
  375. // This is a single edit surrounded by equalities.
  376. var equality1 = diffs[pointer - 1][1];
  377. var edit = diffs[pointer][1];
  378. var equality2 = diffs[pointer + 1][1]; // First, shift the edit as far left as possible.
  379. var commonOffset = diff_commonSuffix(equality1, edit);
  380. if (commonOffset) {
  381. var commonString = edit.substring(edit.length - commonOffset);
  382. equality1 = equality1.substring(0, equality1.length - commonOffset);
  383. edit = commonString + edit.substring(0, edit.length - commonOffset);
  384. equality2 = commonString + equality2;
  385. } // Second, step character by character right, looking for the best fit.
  386. var bestEquality1 = equality1;
  387. var bestEdit = edit;
  388. var bestEquality2 = equality2;
  389. var bestScore =
  390. diff_cleanupSemanticScore_(equality1, edit) +
  391. diff_cleanupSemanticScore_(edit, equality2);
  392. while (edit.charAt(0) === equality2.charAt(0)) {
  393. equality1 += edit.charAt(0);
  394. edit = edit.substring(1) + equality2.charAt(0);
  395. equality2 = equality2.substring(1);
  396. var score =
  397. diff_cleanupSemanticScore_(equality1, edit) +
  398. diff_cleanupSemanticScore_(edit, equality2); // The >= encourages trailing rather than leading whitespace on edits.
  399. if (score >= bestScore) {
  400. bestScore = score;
  401. bestEquality1 = equality1;
  402. bestEdit = edit;
  403. bestEquality2 = equality2;
  404. }
  405. }
  406. if (diffs[pointer - 1][1] != bestEquality1) {
  407. // We have an improvement, save it back to the diff.
  408. if (bestEquality1) {
  409. diffs[pointer - 1][1] = bestEquality1;
  410. } else {
  411. diffs.splice(pointer - 1, 1);
  412. pointer--;
  413. }
  414. diffs[pointer][1] = bestEdit;
  415. if (bestEquality2) {
  416. diffs[pointer + 1][1] = bestEquality2;
  417. } else {
  418. diffs.splice(pointer + 1, 1);
  419. pointer--;
  420. }
  421. }
  422. }
  423. pointer++;
  424. }
  425. }; // Define some regex patterns for matching boundaries.
  426. var nonAlphaNumericRegex_ = /[^a-zA-Z0-9]/;
  427. var whitespaceRegex_ = /\s/;
  428. var linebreakRegex_ = /[\r\n]/;
  429. var blanklineEndRegex_ = /\n\r?\n$/;
  430. var blanklineStartRegex_ = /^\r?\n\r?\n/;
  431. /**
  432. * Reorder and merge like edit sections. Merge equalities.
  433. * Any edit section can move as long as it doesn't cross an equality.
  434. * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
  435. */
  436. var diff_cleanupMerge = function (diffs) {
  437. // Add a dummy entry at the end.
  438. diffs.push(new Diff(DIFF_EQUAL, ''));
  439. var pointer = 0;
  440. var count_delete = 0;
  441. var count_insert = 0;
  442. var text_delete = '';
  443. var text_insert = '';
  444. var commonlength;
  445. while (pointer < diffs.length) {
  446. switch (diffs[pointer][0]) {
  447. case DIFF_INSERT:
  448. count_insert++;
  449. text_insert += diffs[pointer][1];
  450. pointer++;
  451. break;
  452. case DIFF_DELETE:
  453. count_delete++;
  454. text_delete += diffs[pointer][1];
  455. pointer++;
  456. break;
  457. case DIFF_EQUAL:
  458. // Upon reaching an equality, check for prior redundancies.
  459. if (count_delete + count_insert > 1) {
  460. if (count_delete !== 0 && count_insert !== 0) {
  461. // Factor out any common prefixies.
  462. commonlength = diff_commonPrefix(text_insert, text_delete);
  463. if (commonlength !== 0) {
  464. if (
  465. pointer - count_delete - count_insert > 0 &&
  466. diffs[pointer - count_delete - count_insert - 1][0] ==
  467. DIFF_EQUAL
  468. ) {
  469. diffs[pointer - count_delete - count_insert - 1][1] +=
  470. text_insert.substring(0, commonlength);
  471. } else {
  472. diffs.splice(
  473. 0,
  474. 0,
  475. new Diff(DIFF_EQUAL, text_insert.substring(0, commonlength))
  476. );
  477. pointer++;
  478. }
  479. text_insert = text_insert.substring(commonlength);
  480. text_delete = text_delete.substring(commonlength);
  481. } // Factor out any common suffixies.
  482. commonlength = diff_commonSuffix(text_insert, text_delete);
  483. if (commonlength !== 0) {
  484. diffs[pointer][1] =
  485. text_insert.substring(text_insert.length - commonlength) +
  486. diffs[pointer][1];
  487. text_insert = text_insert.substring(
  488. 0,
  489. text_insert.length - commonlength
  490. );
  491. text_delete = text_delete.substring(
  492. 0,
  493. text_delete.length - commonlength
  494. );
  495. }
  496. } // Delete the offending records and add the merged ones.
  497. pointer -= count_delete + count_insert;
  498. diffs.splice(pointer, count_delete + count_insert);
  499. if (text_delete.length) {
  500. diffs.splice(pointer, 0, new Diff(DIFF_DELETE, text_delete));
  501. pointer++;
  502. }
  503. if (text_insert.length) {
  504. diffs.splice(pointer, 0, new Diff(DIFF_INSERT, text_insert));
  505. pointer++;
  506. }
  507. pointer++;
  508. } else if (pointer !== 0 && diffs[pointer - 1][0] == DIFF_EQUAL) {
  509. // Merge this equality with the previous one.
  510. diffs[pointer - 1][1] += diffs[pointer][1];
  511. diffs.splice(pointer, 1);
  512. } else {
  513. pointer++;
  514. }
  515. count_insert = 0;
  516. count_delete = 0;
  517. text_delete = '';
  518. text_insert = '';
  519. break;
  520. }
  521. }
  522. if (diffs[diffs.length - 1][1] === '') {
  523. diffs.pop(); // Remove the dummy entry at the end.
  524. } // Second pass: look for single edits surrounded on both sides by equalities
  525. // which can be shifted sideways to eliminate an equality.
  526. // e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
  527. var changes = false;
  528. pointer = 1; // Intentionally ignore the first and last element (don't need checking).
  529. while (pointer < diffs.length - 1) {
  530. if (
  531. diffs[pointer - 1][0] == DIFF_EQUAL &&
  532. diffs[pointer + 1][0] == DIFF_EQUAL
  533. ) {
  534. // This is a single edit surrounded by equalities.
  535. if (
  536. diffs[pointer][1].substring(
  537. diffs[pointer][1].length - diffs[pointer - 1][1].length
  538. ) == diffs[pointer - 1][1]
  539. ) {
  540. // Shift the edit over the previous equality.
  541. diffs[pointer][1] =
  542. diffs[pointer - 1][1] +
  543. diffs[pointer][1].substring(
  544. 0,
  545. diffs[pointer][1].length - diffs[pointer - 1][1].length
  546. );
  547. diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
  548. diffs.splice(pointer - 1, 1);
  549. changes = true;
  550. } else if (
  551. diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) ==
  552. diffs[pointer + 1][1]
  553. ) {
  554. // Shift the edit over the next equality.
  555. diffs[pointer - 1][1] += diffs[pointer + 1][1];
  556. diffs[pointer][1] =
  557. diffs[pointer][1].substring(diffs[pointer + 1][1].length) +
  558. diffs[pointer + 1][1];
  559. diffs.splice(pointer + 1, 1);
  560. changes = true;
  561. }
  562. }
  563. pointer++;
  564. } // If shifts were made, the diff needs reordering and another shift sweep.
  565. if (changes) {
  566. diff_cleanupMerge(diffs);
  567. }
  568. };