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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
37864fb0
Commit
37864fb0
authored
Nov 16, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Multi-file editor dirty diff indicator
[ci skip]
parent
4d89f520
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
6 deletions
+64
-6
app/assets/javascripts/repo/components/repo_editor.vue
app/assets/javascripts/repo/components/repo_editor.vue
+44
-6
app/assets/stylesheets/pages/repo.scss
app/assets/stylesheets/pages/repo.scss
+20
-0
No files found.
app/assets/javascripts/repo/components/repo_editor.vue
View file @
37864fb0
...
...
@@ -14,8 +14,9 @@ export default {
if
(
this
.
monaco
)
{
this
.
initMonaco
();
}
else
{
monacoLoader
([
'
vs/editor/editor.main
'
],
(
)
=>
{
monacoLoader
([
'
vs/editor/editor.main
'
,
'
vs/editor/common/diff/diffComputer
'
],
(
_
,
{
DiffComputer
}
)
=>
{
this
.
monaco
=
monaco
;
this
.
DiffComputer
=
DiffComputer
;
this
.
initMonaco
();
});
...
...
@@ -44,8 +45,6 @@ export default {
});
this
.
languages
=
this
.
monaco
.
languages
.
getLanguages
();
this
.
addMonacoEvents
();
}
this
.
setupEditor
();
...
...
@@ -62,11 +61,50 @@ export default {
const
newModel
=
this
.
monaco
.
editor
.
createModel
(
content
,
foundLang
?
foundLang
.
id
:
'
plaintext
'
,
);
const
originalLines
=
this
.
monaco
.
editor
.
createModel
(
this
.
activeFile
.
raw
,
foundLang
?
foundLang
.
id
:
'
plaintext
'
,
).
getLinesContent
();
this
.
monacoInstance
.
setModel
(
newModel
);
this
.
decorations
=
[];
const
modifiedType
=
(
change
)
=>
{
if
(
change
.
originalEndLineNumber
===
0
)
{
return
'
added
'
;
}
else
if
(
change
.
modifiedEndLineNumber
===
0
)
{
return
'
removed
'
;
}
return
'
modified
'
;
};
this
.
monacoModelChangeContents
=
newModel
.
onDidChangeContent
(()
=>
{
const
diffComputer
=
new
this
.
DiffComputer
(
originalLines
,
newModel
.
getLinesContent
(),
{
shouldPostProcessCharChanges
:
true
,
shouldIgnoreTrimWhitespace
:
true
,
shouldMakePrettyDiff
:
true
,
},
addMonacoEvents
()
{
this
.
monacoInstance
.
onKeyUp
(()
=>
{
);
this
.
decorations
=
this
.
monacoInstance
.
deltaDecorations
(
this
.
decorations
,
diffComputer
.
computeDiff
().
map
(
change
=>
({
range
:
new
monaco
.
Range
(
change
.
modifiedStartLineNumber
,
1
,
!
change
.
modifiedEndLineNumber
?
change
.
modifiedStartLineNumber
:
change
.
modifiedEndLineNumber
,
1
,
),
options
:
{
isWholeLine
:
true
,
linesDecorationsClassName
:
`dirty-diff dirty-diff-
${
modifiedType
(
change
)}
`
,
},
})),
);
this
.
changeFileContent
({
file
:
this
.
activeFile
,
content
:
this
.
monacoInstance
.
getValue
(),
...
...
app/assets/stylesheets/pages/repo.scss
View file @
37864fb0
...
...
@@ -302,3 +302,23 @@
.multi-file-table-col-name
{
width
:
350px
;
}
.dirty-diff
{
// !important need to override monaco inline style
width
:
4px
!
important
;
left
:
0
!
important
;
&
-modified
{
background-color
:
rgb
(
19
,
117
,
150
);
}
&
-added
{
background-color
:
rgb
(
89
,
119
,
11
);
}
&
-removed
{
height
:
4px
!
important
;
bottom
:
-2px
;
background-color
:
red
;
}
}
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