Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated to return the line changed also

  • Loading branch information...
commit 1ab085a2a01340894be51cb9673a5bae1cd60efd 1 parent bf0075e
Dan Ives authored

Showing 1 changed file with 5 additions and 5 deletions. Show diff stats Hide diff stats

  1. +5 5 diff.js
10 diff.js
@@ -89,11 +89,11 @@ var JsDiff = (function() {
89 89 // and does not pass the bounds of the diff graph
90 90 if (!canAdd || (canRemove && addPath.newPos < removePath.newPos)) {
91 91 basePath = clonePath(removePath);
92   - this.pushComponent(basePath.components, oldString[oldPos], undefined, true);
  92 + this.pushComponent(basePath.components, oldString[oldPos], undefined, true, oldPos);
93 93 } else {
94 94 basePath = clonePath(addPath);
95 95 basePath.newPos++;
96   - this.pushComponent(basePath.components, newString[basePath.newPos], true, undefined);
  96 + this.pushComponent(basePath.components, newString[basePath.newPos], true, undefined, oldPos);
97 97 }
98 98
99 99 var oldPos = this.extractCommon(basePath, newString, oldString, diagonalPath);
@@ -107,15 +107,15 @@ var JsDiff = (function() {
107 107 }
108 108 },
109 109
110   - pushComponent: function(components, value, added, removed) {
  110 + pushComponent: function(components, value, added, removed, oldPos) {
111 111 var last = components[components.length-1];
112 112 if (last && last.added === added && last.removed === removed) {
113 113 // We need to clone here as the component clone operation is just
114 114 // as shallow array clone
115 115 components[components.length-1] =
116   - {value: this.join(last.value, value), added: added, removed: removed };
  116 + {value: this.join(last.value, value), added: added, removed: removed, line: oldPos };
117 117 } else {
118   - components.push({value: value, added: added, removed: removed });
  118 + components.push({value: value, added: added, removed: removed, line: oldPos });
119 119 }
120 120 },
121 121 extractCommon: function(basePath, newString, oldString, diagonalPath) {

0 comments on commit 1ab085a

Please sign in to comment.
Something went wrong with that request. Please try again.