1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Improve diff count for diff-text widget

This commit is contained in:
Jermolene 2018-04-03 17:50:17 +01:00
parent 47cdf55133
commit 0080728d36

View File

@ -57,7 +57,12 @@ DiffTextWidget.prototype.render = function(parent,nextSibling) {
domDiff = this.createDiffDom(diffs);
parent.insertBefore(domContainer,nextSibling);
// Set variables
this.setVariable("diff-count",Math.trunc((diffs.length - 1) / 2).toString());
this.setVariable("diff-count",diffs.reduce(function(acc,diff) {
if(diff[0] !== dmp.DIFF_EQUAL) {
acc++;
}
return acc;
},0).toString());
// Render child widgets
this.renderChildren(domContainer,null);
// Render the diff