diff --git a/qml/js/functions.js b/qml/js/functions.js index b740273..762a301 100644 --- a/qml/js/functions.js +++ b/qml/js/functions.js @@ -235,7 +235,15 @@ function enhanceHtmlEntities(simpleText) { return simpleText.replace(ampRegExp, "&").replace(ltRegExp, "<").replace(gtRegExp, ">");//.replace(rawNewLineRegExp, "
"); } -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) {