Commit e5e9d5d3 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/273179/fixSuggestionsDollarSignReplacement' into 'master'

Fixed diff suggestions not working with dollar signs

See merge request gitlab-org/gitlab!61041
parents 732ea3e8 0b8a984d
......@@ -232,7 +232,7 @@ export function insertMarkdownText({
.join('\n');
}
} else if (tag.indexOf(textPlaceholder) > -1) {
textToInsert = tag.replace(textPlaceholder, selected.replace(/\\n/g, '\n'));
textToInsert = tag.replace(textPlaceholder, () => selected.replace(/\\n/g, '\n'));
} else {
textToInsert = String(startChar) + tag + selected + (wrap ? tag : '');
}
......
---
title: Fixed dollar signs in suggestions getting replaced incorrectly
merge_request: 61041
author:
type: fixed
......@@ -51,6 +51,25 @@ describe('init markdown', () => {
expect(textArea.value).toEqual(`${initialValue}- `);
});
it('inserts dollar signs correctly', () => {
const initialValue = '';
textArea.value = initialValue;
textArea.selectionStart = 0;
textArea.selectionEnd = 0;
insertMarkdownText({
textArea,
text: textArea.value,
tag: '```suggestion:-0+0\n{text}\n```',
blockTag: true,
selected: '# Does not parse the `$` currently.',
wrap: false,
});
expect(textArea.value).toContain('# Does not parse the `$` currently.');
});
it('inserts the tag on a new line if the current one is not empty', () => {
const initialValue = 'some text';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment