mirror of
https://github.com/flynx/diff.js.git
synced 2025-10-29 02:50:10 +00:00
bugfix...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c46c6c394e
commit
2e6591e03e
20
diff.js
20
diff.js
@ -1494,24 +1494,12 @@ Types.set('Text', {
|
||||
|
||||
// XXX this is not efficient...
|
||||
// ...find a way to do all the changes in one go...
|
||||
// would be nice to cache this but then we would need a finalize
|
||||
// stage to apply the results...
|
||||
// XXX add object compatibility checks...
|
||||
patch: function(obj, key, change){
|
||||
var lines = obj.split(/\n/)
|
||||
|
||||
// remove line...
|
||||
if(!('B' in change) || change.B == this.NONE){
|
||||
lines.splice(key, 1)
|
||||
|
||||
// insert line...
|
||||
} else if(!('A' in change) || change.A == this.NONE){
|
||||
lines.splice(key, 0, change.B)
|
||||
|
||||
// replace line...
|
||||
} else {
|
||||
obj.split(/\n/)[key] = change.B
|
||||
}
|
||||
|
||||
return lines.join('\n')
|
||||
return this.typeCall(Array, 'patch', obj.split(/\n/), key, change)
|
||||
.join('\n')
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user