parent
3a1c3c5df5
commit
fd818194f1
|
@ -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;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* 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.computeDiff(model));
|
||||
model.onChange(() => this.throttledComputeDiff(model));
|
||||
}
|
||||
|
||||
computeDiff(model) {
|
||||
|
@ -61,6 +64,8 @@ export default class DirtyDiffController {
|
|||
|
||||
dispose() {
|
||||
this.disposable.dispose();
|
||||
|
||||
this.dirtyDiffWorker.removeEventListener('message', this.decorate);
|
||||
this.dirtyDiffWorker.terminate();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { diffLines } from 'diff';
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const computeDiff = (originalContent, newContent) => {
|
||||
const changes = diffLines(originalContent, newContent);
|
||||
|
||||
|
|
|
@ -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/,
|
||||
|
|
Loading…
Reference in New Issue