Skip to content

Commit

Permalink
Sort text replacements better to avoid overlaps, fixes #334
Browse files Browse the repository at this point in the history
  • Loading branch information
Wunderfitz committed Feb 10, 2021
1 parent fc2c53f commit 4435828
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion qml/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down

0 comments on commit 4435828

Please sign in to comment.