From d2602c47a65ca523185278ec14c719cf08327e49 Mon Sep 17 00:00:00 2001 From: Gabriel Wicke Date: Mon, 4 Jun 2012 00:02:49 +0200 Subject: [PATCH] Switch back to word-based diff The char-based diff looked good in some pages, but yielded terrible results in others. The word-based algo is more consistent overall. Change-Id: I7f2d40315ad96df037c2d9a1d50739e3d21b6c81 --- api/ParserService.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/ParserService.js b/api/ParserService.js index 4c913405f1..807691ca9a 100644 --- a/api/ParserService.js +++ b/api/ParserService.js @@ -127,7 +127,7 @@ app.post(/\/_wikitext\/(.*)/, function(req, res){ }); /** - * Perform char-based diff on a line-based diff. The char-based algorithm is + * Perform word-based diff on a line-based diff. The word-based algorithm is * practically unusable for inputs > 5k bytes, so we only perform it on the * output of the more efficient line-based diff. */ @@ -140,7 +140,7 @@ var refineDiff = function( diff ) { added = d; } else if ( d.removed ) { if ( added ) { - var fineDiff = jsDiff.diffChars( d.value, added.value ); + var fineDiff = jsDiff.diffWords( d.value, added.value ); out.push.apply( out, fineDiff ); added = null; } @@ -185,7 +185,7 @@ app.get(/\/_roundtrip\/(.*)/, function(req, res){ var patch; if ( src.length < 4000 ) { // Use word-based diff for small articles - patch = jsDiff.convertChangesToXML( jsDiff.diffChars( out, src ) ); + patch = jsDiff.convertChangesToXML( jsDiff.diffWords( out, src ) ); } else { patch = jsDiff.convertChangesToXML( refineDiff( jsDiff.diffLines( out, src ) ) ); }