Skip to content

Commit c0ec747

Browse files
author
Bill Long
committed
Properly increment unicode value
1 parent 34d1366 commit c0ec747

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

angular-rich-text-diff.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var AngularRichTextDiff;
1616
_this.doDiff();
1717
});
1818
this.tagMap = {};
19+
this.mapLength = 0;
1920
this.dmp = new diff_match_patch();
2021
this.doDiff();
2122
}
@@ -92,9 +93,10 @@ var AngularRichTextDiff;
9293
var unicodeCharacter = this.tagMap[tagString];
9394
if (unicodeCharacter === undefined) {
9495
// Nope, need to map it
95-
unicodeCharacter = String.fromCharCode(this.unicodeRangeStart + this.tagMap.length);
96+
unicodeCharacter = String.fromCharCode(this.unicodeRangeStart + this.mapLength);
9697
this.tagMap[tagString] = unicodeCharacter;
9798
this.tagMap[unicodeCharacter] = tagString;
99+
this.mapLength++;
98100
}
99101
// At this point it has been mapped, so now we can use it
100102
diffableString += htmlString.substr(offset, tagStart - offset);

angular-rich-text-diff.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ module AngularRichTextDiff {
2121

2222
unicodeRangeStart = 0xE000;
2323
tagMap: any;
24+
mapLength: number;
2425
dmp: diff_match_patch;
2526

2627
constructor(public $scope: IRichTextDiffScope, public $sce: ng.ISCEService) {
2728
$scope.$watch('left', () => { this.doDiff(); });
2829
$scope.$watch('right', () => { this.doDiff(); });
2930
this.tagMap = {};
31+
this.mapLength = 0;
3032
this.dmp = new diff_match_patch();
3133
this.doDiff();
3234
}
@@ -110,9 +112,10 @@ module AngularRichTextDiff {
110112
var unicodeCharacter = this.tagMap[tagString];
111113
if (unicodeCharacter === undefined) {
112114
// Nope, need to map it
113-
unicodeCharacter = String.fromCharCode(this.unicodeRangeStart + this.tagMap.length);
115+
unicodeCharacter = String.fromCharCode(this.unicodeRangeStart + this.mapLength);
114116
this.tagMap[tagString] = unicodeCharacter;
115117
this.tagMap[unicodeCharacter] = tagString;
118+
this.mapLength++;
116119
}
117120

118121
// At this point it has been mapped, so now we can use it

0 commit comments

Comments
 (0)