From 354042ac2ac6f2efffa43f6fa5bf6ac49335ebf5 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 12 Jun 2017 15:27:13 -0700 Subject: [PATCH] :lipstick: --- .../electron-browser/terminalActions.ts | 1 - .../electron-browser/terminalInstance.ts | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts index 1c7a798b747..6ead524b144 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalActions.ts @@ -581,6 +581,5 @@ export class RenameTerminalAction extends Action { terminalInstance.setTitle(name); } }); - } } diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts index 2909a276483..abf9d69364d 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts @@ -62,7 +62,6 @@ export class TerminalInstance implements ITerminalInstance { private _isDisposed: boolean; private _onDisposed: Emitter; private _onDataForApi: Emitter<{ instance: ITerminalInstance, data: string }>; - private _onMessageTitleCheck: (message: any) => void; private _onProcessIdReady: Emitter; private _onTitleChanged: Emitter; private _process: cp.ChildProcess; @@ -77,6 +76,7 @@ export class TerminalInstance implements ITerminalInstance { private _terminalHasTextContextKey: IContextKey; private _cols: number; private _rows: number; + private _messageTitleListener: (message: { type: string, content: string }) => void; private _widgetManager: TerminalWidgetManager; private _linkHandler: TerminalLinkHandler; @@ -495,13 +495,13 @@ export class TerminalInstance implements ITerminalInstance { }); if (!shell.name) { // Only listen for process title changes when a name is not provided - this._onMessageTitleCheck = (message) => { + this._messageTitleListener = (message) => { if (message.type === 'title') { this._title = message.content ? message.content : ''; this._onTitleChanged.fire(this._title); } }; - this._process.on('message', this._onMessageTitleCheck); + this._process.on('message', this._messageTitleListener); } this._process.on('message', (message) => { if (message.type === 'pid') { @@ -782,15 +782,16 @@ export class TerminalInstance implements ITerminalInstance { } public setTitle(title: string): void { - const oldTitle = this._title; - if (title !== oldTitle) { - this._title = title; + const didTitleChange = title !== this._title; + if (didTitleChange) { this._onTitleChanged.fire(title); } - // if the title is set via API, unregister the handler that automatically updates the terminal name - if (this._process) { - this._process.removeListener('message', this._onMessageTitleCheck); + // If the title was not set by the API, unregister the handler that + // automatically updates the terminal name + if (this._process && this._messageTitleListener) { + this._process.removeListener('message', this._messageTitleListener); + this._messageTitleListener = null; } } }