Commit 53707c83 authored by Phil Hughes's avatar Phil Hughes

remove pending tab when opening a file from the left sidebar

parent a515b459
...@@ -28,10 +28,7 @@ export default class Model { ...@@ -28,10 +28,7 @@ export default class Model {
this.dispose = this.dispose.bind(this); this.dispose = this.dispose.bind(this);
eventHub.$on(`editor.update.model.dispose.${this.file.key}`, this.dispose); eventHub.$on(`editor.update.model.dispose.${this.file.key}`, this.dispose);
eventHub.$on( eventHub.$on(`editor.update.model.content.${this.file.path}`, this.updateContent);
`editor.update.model.content.${this.file.path}`,
this.updateContent,
);
} }
get url() { get url() {
...@@ -79,9 +76,6 @@ export default class Model { ...@@ -79,9 +76,6 @@ export default class Model {
this.events.clear(); this.events.clear();
eventHub.$off(`editor.update.model.dispose.${this.file.key}`, this.dispose); eventHub.$off(`editor.update.model.dispose.${this.file.key}`, this.dispose);
eventHub.$off( eventHub.$off(`editor.update.model.content.${this.file.path}`, this.updateContent);
`editor.update.model.content.${this.file.path}`,
this.updateContent,
);
} }
} }
...@@ -37,10 +37,7 @@ export default class ModelManager { ...@@ -37,10 +37,7 @@ export default class ModelManager {
removeCachedModel(file) { removeCachedModel(file) {
this.models.delete(file.key); this.models.delete(file.key);
eventHub.$off( eventHub.$off(`editor.update.model.dispose.${file.key}`, this.removeCachedModel);
`editor.update.model.dispose.${file.key}`,
this.removeCachedModel,
);
} }
dispose() { dispose() {
......
...@@ -24,7 +24,9 @@ export default { ...@@ -24,7 +24,9 @@ export default {
}); });
if (state.entries[path].opened) { if (state.entries[path].opened) {
state.openFiles.push(state.entries[path]); Object.assign(state, {
openFiles: state.openFiles.filter(f => f.path !== path).concat(state.entries[path]),
});
} else { } else {
const file = state.entries[path]; const file = state.entries[path];
......
...@@ -36,9 +36,7 @@ describe('Multi-file editor library decorations controller', () => { ...@@ -36,9 +36,7 @@ describe('Multi-file editor library decorations controller', () => {
}); });
it('returns decorations by model URL', () => { it('returns decorations by model URL', () => {
controller.addDecorations(model, 'key', [ controller.addDecorations(model, 'key', [{ decoration: 'decorationValue' }]);
{ decoration: 'decorationValue' },
]);
const decorations = controller.getAllDecorationsForModel(model); const decorations = controller.getAllDecorationsForModel(model);
...@@ -48,39 +46,29 @@ describe('Multi-file editor library decorations controller', () => { ...@@ -48,39 +46,29 @@ describe('Multi-file editor library decorations controller', () => {
describe('addDecorations', () => { describe('addDecorations', () => {
it('caches decorations in a new map', () => { it('caches decorations in a new map', () => {
controller.addDecorations(model, 'key', [ controller.addDecorations(model, 'key', [{ decoration: 'decorationValue' }]);
{ decoration: 'decorationValue' },
]);
expect(controller.decorations.size).toBe(1); expect(controller.decorations.size).toBe(1);
}); });
it('does not create new cache model', () => { it('does not create new cache model', () => {
controller.addDecorations(model, 'key', [ controller.addDecorations(model, 'key', [{ decoration: 'decorationValue' }]);
{ decoration: 'decorationValue' }, controller.addDecorations(model, 'key', [{ decoration: 'decorationValue2' }]);
]);
controller.addDecorations(model, 'key', [
{ decoration: 'decorationValue2' },
]);
expect(controller.decorations.size).toBe(1); expect(controller.decorations.size).toBe(1);
}); });
it('caches decorations by model URL', () => { it('caches decorations by model URL', () => {
controller.addDecorations(model, 'key', [ controller.addDecorations(model, 'key', [{ decoration: 'decorationValue' }]);
{ decoration: 'decorationValue' },
]);
expect(controller.decorations.size).toBe(1); expect(controller.decorations.size).toBe(1);
expect(controller.decorations.keys().next().value).toBe('path'); expect(controller.decorations.keys().next().value).toBe('path--path');
}); });
it('calls decorate method', () => { it('calls decorate method', () => {
spyOn(controller, 'decorate'); spyOn(controller, 'decorate');
controller.addDecorations(model, 'key', [ controller.addDecorations(model, 'key', [{ decoration: 'decorationValue' }]);
{ decoration: 'decorationValue' },
]);
expect(controller.decorate).toHaveBeenCalled(); expect(controller.decorate).toHaveBeenCalled();
}); });
...@@ -92,10 +80,7 @@ describe('Multi-file editor library decorations controller', () => { ...@@ -92,10 +80,7 @@ describe('Multi-file editor library decorations controller', () => {
controller.decorate(model); controller.decorate(model);
expect(controller.editor.instance.deltaDecorations).toHaveBeenCalledWith( expect(controller.editor.instance.deltaDecorations).toHaveBeenCalledWith([], []);
[],
[],
);
}); });
it('caches decorations', () => { it('caches decorations', () => {
...@@ -111,15 +96,13 @@ describe('Multi-file editor library decorations controller', () => { ...@@ -111,15 +96,13 @@ describe('Multi-file editor library decorations controller', () => {
controller.decorate(model); controller.decorate(model);
expect(controller.editorDecorations.keys().next().value).toBe('path'); expect(controller.editorDecorations.keys().next().value).toBe('path--path');
}); });
}); });
describe('dispose', () => { describe('dispose', () => {
it('clears cached decorations', () => { it('clears cached decorations', () => {
controller.addDecorations(model, 'key', [ controller.addDecorations(model, 'key', [{ decoration: 'decorationValue' }]);
{ decoration: 'decorationValue' },
]);
controller.dispose(); controller.dispose();
...@@ -127,9 +110,7 @@ describe('Multi-file editor library decorations controller', () => { ...@@ -127,9 +110,7 @@ describe('Multi-file editor library decorations controller', () => {
}); });
it('clears cached editorDecorations', () => { it('clears cached editorDecorations', () => {
controller.addDecorations(model, 'key', [ controller.addDecorations(model, 'key', [{ decoration: 'decorationValue' }]);
{ decoration: 'decorationValue' },
]);
controller.dispose(); controller.dispose();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment