Commit 95bc8490 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/333351/fixSuggestionsNewLines' into 'master'

Fixes suggestions with new line characters not working

See merge request gitlab-org/gitlab!68532
parents df95c9e6 c821d7d5
...@@ -232,7 +232,7 @@ export function insertMarkdownText({ ...@@ -232,7 +232,7 @@ export function insertMarkdownText({
.join('\n'); .join('\n');
} }
} else if (tag.indexOf(textPlaceholder) > -1) { } else if (tag.indexOf(textPlaceholder) > -1) {
textToInsert = tag.replace(textPlaceholder, () => selected.replace(/\\n/g, '\n')); textToInsert = tag.replace(textPlaceholder, () => selected);
} else { } else {
textToInsert = String(startChar) + tag + selected + (wrap ? tag : ''); textToInsert = String(startChar) + tag + selected + (wrap ? tag : '');
} }
......
...@@ -70,6 +70,25 @@ describe('init markdown', () => { ...@@ -70,6 +70,25 @@ describe('init markdown', () => {
expect(textArea.value).toContain('# Does not parse the `$` currently.'); expect(textArea.value).toContain('# Does not parse the `$` currently.');
}); });
it('inserts a new line 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 \\n currently.',
wrap: false,
});
expect(textArea.value).toContain('# Does not parse the \\n currently.');
});
it('inserts the tag on a new line if the current one is not empty', () => { it('inserts the tag on a new line if the current one is not empty', () => {
const initialValue = 'some text'; 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