Sort text replacements better to avoid overlaps, fixes #334

This commit is contained in:
Sebastian Wolf 2021-02-10 22:02:53 +01:00
parent fc2c53f840
commit 4435828ff7
No known key found for this signature in database
GPG key ID: CEA9522B5F38A90A

View file

@ -235,7 +235,15 @@ function enhanceHtmlEntities(simpleText) {
return simpleText.replace(ampRegExp, "&amp;").replace(ltRegExp, "&lt;").replace(gtRegExp, "&gt;");//.replace(rawNewLineRegExp, "<br>");
}
function messageInsertionSorter(a, b) { return (b.offset+b.removeLength) - (a.offset+a.removeLength) }
function messageInsertionSorter(a, b) {
if ((b.offset + b.removeLength) > (a.offset + a.removeLength)) {
return 1;
}
if ((b.offset + b.removeLength) < (a.offset + a.removeLength)) {
return -1;
}
return b.offset - a.offset;
}
function enhanceMessageText(formattedText, ignoreEntities) {