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
Léo-Paul Géneau
gitlab-ce
Commits
fd818194
Commit
fd818194
authored
Nov 22, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed web worker performance
[ci skip]
parent
3a1c3c5d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
4 deletions
+14
-4
app/assets/javascripts/repo/components/repo_editor.vue
app/assets/javascripts/repo/components/repo_editor.vue
+1
-1
app/assets/javascripts/repo/lib/diff/controller.js
app/assets/javascripts/repo/lib/diff/controller.js
+8
-3
app/assets/javascripts/repo/lib/diff/diff.js
app/assets/javascripts/repo/lib/diff/diff.js
+1
-0
app/assets/javascripts/repo/lib/diff/diff_worker.js
app/assets/javascripts/repo/lib/diff/diff_worker.js
+0
-0
config/webpack.config.js
config/webpack.config.js
+4
-0
No files found.
app/assets/javascripts/repo/components/repo_editor.vue
View file @
fd818194
...
...
@@ -35,7 +35,7 @@ export default {
this
.
editor
.
createInstance
(
this
.
$el
);
})
.
then
(()
=>
this
.
setupEditor
())
.
catch
((
e
)
=>
{
throw
e
;
flash
(
'
Error setting up monaco. Please try again.
'
);
}
);
.
catch
((
)
=>
flash
(
'
Error setting up monaco. Please try again.
'
)
);
},
setupEditor
()
{
if
(
!
this
.
activeFile
)
return
;
...
...
app/assets/javascripts/repo/lib/diff/controller.js
View file @
fd818194
/* global monaco */
import
DirtyDiffWorker
from
'
worker-loader!./worker.diff
'
;
import
{
throttle
}
from
'
underscore
'
;
import
DirtyDiffWorker
from
'
./diff_worker
'
;
import
Disposable
from
'
../common/disposable
'
;
export
const
getDiffChangeType
=
(
change
)
=>
{
...
...
@@ -34,12 +35,14 @@ export default class DirtyDiffController {
this
.
modelManager
=
modelManager
;
this
.
decorationsController
=
decorationsController
;
this
.
dirtyDiffWorker
=
new
DirtyDiffWorker
();
this
.
throttledComputeDiff
=
throttle
(
this
.
computeDiff
,
250
);
this
.
decorate
=
this
.
decorate
.
bind
(
this
);
this
.
dirtyDiffWorker
.
addEventListener
(
'
message
'
,
e
=>
this
.
decorate
(
e
)
);
this
.
dirtyDiffWorker
.
addEventListener
(
'
message
'
,
this
.
decorate
);
}
attachModel
(
model
)
{
model
.
onChange
(()
=>
this
.
c
omputeDiff
(
model
));
model
.
onChange
(()
=>
this
.
throttledC
omputeDiff
(
model
));
}
computeDiff
(
model
)
{
...
...
@@ -61,6 +64,8 @@ export default class DirtyDiffController {
dispose
()
{
this
.
disposable
.
dispose
();
this
.
dirtyDiffWorker
.
removeEventListener
(
'
message
'
,
this
.
decorate
);
this
.
dirtyDiffWorker
.
terminate
();
}
}
app/assets/javascripts/repo/lib/diff/diff.js
View file @
fd818194
import
{
diffLines
}
from
'
diff
'
;
// eslint-disable-next-line import/prefer-default-export
export
const
computeDiff
=
(
originalContent
,
newContent
)
=>
{
const
changes
=
diffLines
(
originalContent
,
newContent
);
...
...
app/assets/javascripts/repo/lib/diff/
worker.diff
.js
→
app/assets/javascripts/repo/lib/diff/
diff_worker
.js
View file @
fd818194
File moved
config/webpack.config.js
View file @
fd818194
...
...
@@ -116,6 +116,10 @@ var config = {
loader
:
'
url-loader
'
,
options
:
{
limit
:
2048
},
},
{
test
:
/
\_
worker
\.
js$/
,
loader
:
'
worker-loader
'
,
},
{
test
:
/
\.(
worker
(\.
min
)?\.
js|pdf|bmpr
)
$/
,
exclude
:
/node_modules/
,
...
...
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