While using CodeMirror’s
merge addon, I am interested in knowing the count of differences found in the L.H.S. and the R.H.S.
Is there a way of displaying the count?
You could implement it yourself, by using the diff-match-patch library that the
merge addon depends on. Write an
updateDiffCount function that uses the following algorithm:
- Get the two text versions you are comparing as strings.
diff_mainon the strings and
diff_cleanupSemanticon the result, as in this code example.
- Loop through the results and count the result arrays whose first element is not
- Set the text contents of some element on your page to that count.
updateDiffCount function whenever the text in the
textarea is edited, after a delay.