Merge pull request #128 from jgibbon/bugfix/entity-sort

entity sort offset+length
This commit is contained in:
Sebastian Wolf 2020-11-03 20:46:38 +01:00 committed by GitHub
commit 56c5fe2d36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -253,7 +253,7 @@ function enhanceMessageText(formattedText) {
} }
} }
messageInsertions.sort( function(a, b) { return b.offset - a.offset } ); messageInsertions.sort( function(a, b) { return (b.offset+b.removeLength) - (a.offset+a.removeLength) } );
for (var z = 0; z < messageInsertions.length; z++) { for (var z = 0; z < messageInsertions.length; z++) {
messageText = messageText.substring(0, messageInsertions[z].offset) + messageInsertions[z].insertionString + messageText.substring(messageInsertions[z].offset + messageInsertions[z].removeLength); messageText = messageText.substring(0, messageInsertions[z].offset) + messageInsertions[z].insertionString + messageText.substring(messageInsertions[z].offset + messageInsertions[z].removeLength);