Skip to content
Snippets Groups Projects
Unverified Commit e6f1209e authored by Phil Hughes's avatar Phil Hughes
Browse files

Fixes diff sugestions removing dashes from diff

parent c20f0564
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -89,7 +89,6 @@ export default {
return this.referencedUsers.length >= referencedUsersThreshold;
},
lineContent() {
const FIRST_CHAR_REGEX = /^(\+|-)/;
const [firstSuggestion] = this.suggestions;
if (firstSuggestion) {
return firstSuggestion.from_content;
Loading
Loading
@@ -99,7 +98,7 @@ export default {
const { rich_text: richText, text } = this.line;
 
if (text) {
return text.replace(FIRST_CHAR_REGEX, '');
return text;
}
 
return _.unescape(stripHtml(richText).replace(/\n/g, ''));
Loading
Loading
Loading
Loading
@@ -82,13 +82,12 @@ export default {
// extracts the suggested lines from the markdown
// calculates a line number for each line
 
const FIRST_CHAR_REGEX = /^(\+|-)/;
const newLines = suggestionEl.querySelectorAll('.line');
const fromLine = this.suggestions.length ? this.suggestions[0].from_line : this.fromLine;
const lines = [];
 
newLines.forEach((line, i) => {
const content = `${line.innerText.replace(FIRST_CHAR_REGEX, '')}\n`;
const content = `${line.innerText}\n`;
const lineNumber = fromLine + i;
lines.push({ content, lineNumber });
});
Loading
Loading
---
title: Fixed diff suggestions removing dashes
merge_request:
author:
type: fixed
Loading
Loading
@@ -29,7 +29,7 @@ const generateLine = content => {
const generateMockLines = () => {
const line1 = generateLine('Line 1');
const line2 = generateLine('Line 2');
const line3 = generateLine('Line 3');
const line3 = generateLine('- Line 3');
const container = document.createElement('div');
 
container.appendChild(line1);
Loading
Loading
@@ -80,7 +80,7 @@ describe('Suggestion component', () => {
const expectedReturn = [
{ content: 'Line 1\n', lineNumber: 1 },
{ content: 'Line 2\n', lineNumber: 2 },
{ content: 'Line 3\n', lineNumber: 3 },
{ content: '- Line 3\n', lineNumber: 3 },
];
 
expect(vm.extractNewLines(generateMockLines())).toEqual(expectedReturn);
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