| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 Diff.Diff = { | 4 Diff.Diff = { |
| 5 /** | 5 /** |
| 6 * @param {string} text1 | 6 * @param {string} text1 |
| 7 * @param {string} text2 | 7 * @param {string} text2 |
| 8 * @param {boolean=} cleanup |
| 8 * @return {!Array.<!{0: number, 1: string}>} | 9 * @return {!Array.<!{0: number, 1: string}>} |
| 9 */ | 10 */ |
| 10 charDiff: function(text1, text2) { | 11 charDiff: function(text1, text2, cleanup) { |
| 11 var differ = new diff_match_patch(); | 12 var differ = new diff_match_patch(); |
| 12 return differ.diff_main(text1, text2); | 13 var diff = differ.diff_main(text1, text2); |
| 14 if (cleanup) |
| 15 differ.diff_cleanupSemantic(diff); |
| 16 return diff; |
| 13 }, | 17 }, |
| 14 | 18 |
| 15 /** | 19 /** |
| 16 * @param {!Array.<string>} lines1 | 20 * @param {!Array.<string>} lines1 |
| 17 * @param {!Array.<string>} lines2 | 21 * @param {!Array.<string>} lines2 |
| 18 * @return {!Diff.Diff.DiffArray} | 22 * @return {!Diff.Diff.DiffArray} |
| 19 */ | 23 */ |
| 20 lineDiff: function(lines1, lines2) { | 24 lineDiff: function(lines1, lines2) { |
| 21 /** @type {!Common.CharacterIdMap<string>} */ | 25 /** @type {!Common.CharacterIdMap<string>} */ |
| 22 var idMap = new Common.CharacterIdMap(); | 26 var idMap = new Common.CharacterIdMap(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 /** @enum {number} */ | 83 /** @enum {number} */ |
| 80 Diff.Diff.Operation = { | 84 Diff.Diff.Operation = { |
| 81 Equal: 0, | 85 Equal: 0, |
| 82 Insert: 1, | 86 Insert: 1, |
| 83 Delete: -1, | 87 Delete: -1, |
| 84 Edit: 2 | 88 Edit: 2 |
| 85 }; | 89 }; |
| 86 | 90 |
| 87 /** @typedef {!Array<!{0: !Diff.Diff.Operation, 1: !Array<string>}>} */ | 91 /** @typedef {!Array<!{0: !Diff.Diff.Operation, 1: !Array<string>}>} */ |
| 88 Diff.Diff.DiffArray; | 92 Diff.Diff.DiffArray; |
| OLD | NEW |