@@ -68,7 +68,7 @@ Diff.prototype = {
68
68
69
69
// If we have hit the end of both strings, then we are done
70
70
if ( basePath . newPos + 1 >= newLen && oldPos + 1 >= oldLen ) {
71
- return done ( buildValues ( basePath . components , newString , oldString , self . useLongestToken ) ) ;
71
+ return done ( buildValues ( self , basePath . components , newString , oldString , self . useLongestToken ) ) ;
72
72
} else {
73
73
// Otherwise track this path as a potential candidate and continue.
74
74
bestPath [ diagonalPath ] = basePath ;
@@ -156,7 +156,7 @@ Diff.prototype = {
156
156
}
157
157
} ;
158
158
159
- function buildValues ( components , newString , oldString , useLongestToken ) {
159
+ function buildValues ( diff , components , newString , oldString , useLongestToken ) {
160
160
let componentPos = 0 ,
161
161
componentLen = components . length ,
162
162
newPos = 0 ,
@@ -197,6 +197,14 @@ function buildValues(components, newString, oldString, useLongestToken) {
197
197
}
198
198
}
199
199
200
+ // Special case handle for when one terminal is ignored. For this case we merge the
201
+ // terminal into the prior string and drop the change.
202
+ let lastComponent = components [ componentLen - 1 ] ;
203
+ if ( ( lastComponent . added || lastComponent . removed ) && diff . equals ( '' , lastComponent . value ) ) {
204
+ components [ componentLen - 2 ] . value += lastComponent . value ;
205
+ components . pop ( ) ;
206
+ }
207
+
200
208
return components ;
201
209
}
202
210
0 commit comments