Skip to content

Commit

Permalink
Properly increment unicode value
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Long committed Apr 17, 2015
1 parent 34d1366 commit c0ec747
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion angular-rich-text-diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var AngularRichTextDiff;
_this.doDiff();
});
this.tagMap = {};
this.mapLength = 0;
this.dmp = new diff_match_patch();
this.doDiff();
}
Expand Down Expand Up @@ -92,9 +93,10 @@ var AngularRichTextDiff;
var unicodeCharacter = this.tagMap[tagString];
if (unicodeCharacter === undefined) {
// Nope, need to map it
unicodeCharacter = String.fromCharCode(this.unicodeRangeStart + this.tagMap.length);
unicodeCharacter = String.fromCharCode(this.unicodeRangeStart + this.mapLength);
this.tagMap[tagString] = unicodeCharacter;
this.tagMap[unicodeCharacter] = tagString;
this.mapLength++;
}
// At this point it has been mapped, so now we can use it
diffableString += htmlString.substr(offset, tagStart - offset);
Expand Down
5 changes: 4 additions & 1 deletion angular-rich-text-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ module AngularRichTextDiff {

unicodeRangeStart = 0xE000;
tagMap: any;
mapLength: number;
dmp: diff_match_patch;

constructor(public $scope: IRichTextDiffScope, public $sce: ng.ISCEService) {
$scope.$watch('left', () => { this.doDiff(); });
$scope.$watch('right', () => { this.doDiff(); });
this.tagMap = {};
this.mapLength = 0;
this.dmp = new diff_match_patch();
this.doDiff();
}
Expand Down Expand Up @@ -110,9 +112,10 @@ module AngularRichTextDiff {
var unicodeCharacter = this.tagMap[tagString];
if (unicodeCharacter === undefined) {
// Nope, need to map it
unicodeCharacter = String.fromCharCode(this.unicodeRangeStart + this.tagMap.length);
unicodeCharacter = String.fromCharCode(this.unicodeRangeStart + this.mapLength);
this.tagMap[tagString] = unicodeCharacter;
this.tagMap[unicodeCharacter] = tagString;
this.mapLength++;
}

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

0 comments on commit c0ec747

Please sign in to comment.