diff --git a/src/components/rich_content/rich_content.jsx b/src/components/rich_content/rich_content.jsx
index 0aae7a55..e188763f 100644
--- a/src/components/rich_content/rich_content.jsx
+++ b/src/components/rich_content/rich_content.jsx
@@ -247,12 +247,13 @@ const getLinkData = (attrs, children, index) => {
export const preProcessPerLine = (html, greentext, handleLinks) => {
const lastMentions = []
- let nonEmptyIndex = 0
+ let nonEmptyIndex = -1
const newHtml = convertHtmlToLines(html).reverse().map((item, index, array) => {
// Going over each line in reverse to detect last mentions,
// keeping non-text stuff as-is
if (!item.text) return item
const string = item.text
+ nonEmptyIndex += 1
// Greentext stuff
if (greentext && (string.includes('>') || string.includes('<'))) {
@@ -260,10 +261,8 @@ export const preProcessPerLine = (html, greentext, handleLinks) => {
.replace(/@\w+/gi, '') // remove mentions (even failed ones)
.trim()
if (cleanedString.startsWith('>')) {
- nonEmptyIndex += 1
return `${string}`
} else if (cleanedString.startsWith('<')) {
- nonEmptyIndex += 1
return `${string}`
}
}
diff --git a/test/unit/specs/components/rich_content.spec.js b/test/unit/specs/components/rich_content.spec.js
index 20322019..ff491a3a 100644
--- a/test/unit/specs/components/rich_content.spec.js
+++ b/test/unit/specs/components/rich_content.spec.js
@@ -381,4 +381,39 @@ describe('RichContent', () => {
expect(wrapper.html()).to.eql(compwrap(expected))
})
+
+ it('One buggy example', () => {
+ const html = [
+ 'Bruh',
+ 'Bruh',
+ [
+ makeMention('foo'),
+ makeMention('bar'),
+ makeMention('baz')
+ ].join(''),
+ 'Bruh'
+ ].join('
')
+ const expected = [
+ 'Bruh',
+ 'Bruh',
+ [
+ stubMention('foo'),
+ stubMention('bar'),
+ stubMention('baz')
+ ].join(''),
+ 'Bruh'
+ ].join('
')
+
+ const wrapper = shallowMount(RichContent, {
+ localVue,
+ propsData: {
+ handleLinks: true,
+ greentext: true,
+ emoji: [],
+ html
+ }
+ })
+
+ expect(wrapper.html()).to.eql(compwrap(expected))
+ })
})