Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
e6f1209e
Commit
e6f1209e
authored
Dec 21, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes diff sugestions removing dashes from diff
Closes
https://gitlab.com/gitlab-org/gitlab-ce/issues/55634
parent
c20f0564
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
6 deletions
+9
-6
app/assets/javascripts/vue_shared/components/markdown/field.vue
...sets/javascripts/vue_shared/components/markdown/field.vue
+1
-2
app/assets/javascripts/vue_shared/components/markdown/suggestions.vue
...avascripts/vue_shared/components/markdown/suggestions.vue
+1
-2
changelogs/unreleased/suggestion-dashes.yml
changelogs/unreleased/suggestion-dashes.yml
+5
-0
spec/javascripts/vue_shared/components/markdown/suggestions_spec.js
...cripts/vue_shared/components/markdown/suggestions_spec.js
+2
-2
No files found.
app/assets/javascripts/vue_shared/components/markdown/field.vue
View file @
e6f1209e
...
...
@@ -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
;
...
...
@@ -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
,
''
));
...
...
app/assets/javascripts/vue_shared/components/markdown/suggestions.vue
View file @
e6f1209e
...
...
@@ -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
});
});
...
...
changelogs/unreleased/suggestion-dashes.yml
0 → 100644
View file @
e6f1209e
---
title
:
Fixed diff suggestions removing dashes
merge_request
:
author
:
type
:
fixed
spec/javascripts/vue_shared/components/markdown/suggestions_spec.js
View file @
e6f1209e
...
...
@@ -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
);
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment