mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-14 16:04:09 +01:00
💄
This commit is contained in:
@@ -581,6 +581,5 @@ export class RenameTerminalAction extends Action {
|
||||
terminalInstance.setTitle(name);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ export class TerminalInstance implements ITerminalInstance {
|
||||
private _isDisposed: boolean;
|
||||
private _onDisposed: Emitter<ITerminalInstance>;
|
||||
private _onDataForApi: Emitter<{ instance: ITerminalInstance, data: string }>;
|
||||
private _onMessageTitleCheck: (message: any) => void;
|
||||
private _onProcessIdReady: Emitter<TerminalInstance>;
|
||||
private _onTitleChanged: Emitter<string>;
|
||||
private _process: cp.ChildProcess;
|
||||
@@ -77,6 +76,7 @@ export class TerminalInstance implements ITerminalInstance {
|
||||
private _terminalHasTextContextKey: IContextKey<boolean>;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user