Skip to content
Snippets Groups Projects
Commit 95bc8490 authored by Kushal Pandya's avatar Kushal Pandya
Browse files

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
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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);
} else {
textToInsert = String(startChar) + tag + selected + (wrap ? tag : '');
}
Loading
Loading
Loading
Loading
@@ -70,6 +70,25 @@ describe('init markdown', () => {
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', () => {
const initialValue = 'some text';
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment