Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: third_party/WebKit/Source/devtools/front_end/diff/Diff.js

Issue 2349823002: DevTools: Preserve the text when doing a line-by-line diff (Closed)
Patch Set: Docs Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/diff-module-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/diff/Diff.js
diff --git a/third_party/WebKit/Source/devtools/front_end/diff/Diff.js b/third_party/WebKit/Source/devtools/front_end/diff/Diff.js
index 13fc91d1d158fd6ff2df04404b43fce479fd74b3..297b3878c41330eef4b478582480cbeb8f3443b2 100644
--- a/third_party/WebKit/Source/devtools/front_end/diff/Diff.js
+++ b/third_party/WebKit/Source/devtools/front_end/diff/Diff.js
@@ -17,16 +17,31 @@ WebInspector.Diff = {
/**
* @param {!Array.<string>} lines1
* @param {!Array.<string>} lines2
- * @return {!Array.<!{0: number, 1: string}>}
+ * @return {!Array.<!{0: number, 1: !Array.<string>}>}
*/
lineDiff: function(lines1, lines2)
{
+ /** @type {!Map.<string, string>} */
var lineToChar = new Map();
+ /** @type {!Map.<string, string>} */
+ var charToLine = new Map();
var charCode = 33;
var text1 = encode(lines1);
var text2 = encode(lines2);
- return WebInspector.Diff.charDiff(text1, text2);
+ var diff = WebInspector.Diff.charDiff(text1, text2);
+ var lineDiff = [];
+ for (var i = 0; i < diff.length; i++) {
+ var lines = [];
+ for (var j = 0; j < diff[i][1].length; j++)
+ lines.push(charToLine.get(diff[i][1][j]));
+
+ lineDiff.push({
+ 0: diff[i][0],
+ 1: lines
+ });
+ }
+ return lineDiff;
/**
* @param {!Array.<string>} lines
@@ -41,6 +56,7 @@ WebInspector.Diff = {
if (!character) {
character = String.fromCharCode(charCode++);
lineToChar.set(line, character);
+ charToLine.set(character, line);
}
text += character;
}
@@ -49,7 +65,7 @@ WebInspector.Diff = {
},
/**
- * @param {!Array.<!{0: number, 1: string}>} diff
+ * @param {!Array.<!{0: number, 1: !Array.<string>}>} diff
* @return {!Array<!Array<number>>}
*/
convertToEditDiff: function(diff)
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/diff-module-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698