Skip to content

Commit

Permalink
Fix DiffLevenshtein counting single runes as multiple edits
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarkovtsev authored Jan 31, 2018
1 parent 217d392 commit dbf098b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions diffmatchpatch/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -1236,9 +1236,9 @@ func (dmp *DiffMatchPatch) DiffLevenshtein(diffs []Diff) int {
for _, aDiff := range diffs {
switch aDiff.Type {
case DiffInsert:
insertions += len(aDiff.Text)
insertions += utf8.RuneCountInString(aDiff.Text)
case DiffDelete:
deletions += len(aDiff.Text)
deletions += utf8.RuneCountInString(aDiff.Text)
case DiffEqual:
// A deletion and an insertion is one substitution.
levenshtein += max(insertions, deletions)
Expand Down

0 comments on commit dbf098b

Please sign in to comment.