diff --git a/lib/terminal-session.js b/lib/terminal-session.js index 769d04f..cc12817 100644 --- a/lib/terminal-session.js +++ b/lib/terminal-session.js @@ -19,6 +19,8 @@ export default class TerminalSession { this.pty = this.openPseudoterminal(); this.xterm = new Xterm(); + this.disposables.add(this.emitter, this.xterm); + this.handleEvents(); } @@ -37,7 +39,7 @@ export default class TerminalSession { }); // Process Terminal Exit Events - this.pty.on('exit', this.destroy.bind(this)); + this.pty.on('exit', this.dispose.bind(this)); } @@ -88,19 +90,15 @@ export default class TerminalSession { }; } - destroy() { + dispose() { // Kill the Pseudoterminal (pty) Process if (this.pty) this.pty.kill(); - // Dispose of the Terminal Instance - if (this.xterm) this.xterm.dispose(); - - // Notify any observers that this session is being destroyed. + // Notify any observers that this session is being disposed. this.emitter.emit('did-destroy', this); // Clean up any disposables we're responsible for. - this.emitter.dispose(); this.disposables.dispose(); } diff --git a/lib/terminal-view.js b/lib/terminal-view.js index 17649ff..1a87a8a 100644 --- a/lib/terminal-view.js +++ b/lib/terminal-view.js @@ -18,7 +18,7 @@ export default class TerminalView { // Observe the Session to know when it is destroyed so that we can // clean up our state (i.e. remove event observers). // - this.session.onDidDestroy(this.destroy.bind(this)); + this.session.onDidDestroy(this.dispose.bind(this)); // TODO: Documentation says this should be set for Atom... Research! // etch.setScheduler(atom.views); @@ -38,7 +38,7 @@ export default class TerminalView { return etch.update(this); } - destroy() { + dispose() { this.resizeObserver.disconnect(); this.disposables.dispose(); etch.destroy(this); diff --git a/spec/terminal-session-spec.js b/spec/terminal-session-spec.js index 2efd2c5..3a8385d 100644 --- a/spec/terminal-session-spec.js +++ b/spec/terminal-session-spec.js @@ -12,7 +12,7 @@ describe('TerminalSession', () => { }); afterEach(() => { - testSession.destroy(); + testSession.dispose(); }); describe('xterm', () => { diff --git a/spec/terminal-view-spec.js b/spec/terminal-view-spec.js index fb320e3..a591703 100644 --- a/spec/terminal-view-spec.js +++ b/spec/terminal-view-spec.js @@ -15,8 +15,8 @@ describe('TerminalView', () => { }); afterEach(() => { - terminalView.destroy(); - testSession.destroy(); + terminalView.dispose(); + testSession.dispose(); }); describe('focus', () => {