From e338bc417a13e1ba3bfb7c69a2591d7538535ef1 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Tue, 12 Feb 2019 12:44:23 +0100 Subject: [PATCH] only configure tabs if they're focused (fixes #659) --- .../components/baseTerminalTab.component.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/terminus-terminal/src/components/baseTerminalTab.component.ts b/terminus-terminal/src/components/baseTerminalTab.component.ts index 1a37c579..0adb3594 100644 --- a/terminus-terminal/src/components/baseTerminalTab.component.ts +++ b/terminus-terminal/src/components/baseTerminalTab.component.ts @@ -1,4 +1,4 @@ -import { Observable, Subject, Subscription } from 'rxjs' +import { Observable, Subject, Subscription, merge } from 'rxjs' import { first } from 'rxjs/operators' import { ToastrService } from 'ngx-toastr' import { NgZone, OnInit, OnDestroy, Inject, Injector, Optional, ViewChild, HostBinding, Input, ElementRef } from '@angular/core' @@ -200,6 +200,13 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit attachTermContainerHandlers () { this.detachTermContainerHandlers() + + const maybeConfigure = () => { + if (this.hasFocus) { + setTimeout(() => this.configure(), 250) + } + } + this.termContainerSubscriptions = [ this.frontend.title$.subscribe(title => this.zone.run(() => this.setTitle(title))), @@ -262,13 +269,8 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit }) }), - this.hostApp.windowMoved$.subscribe(() => setTimeout(() => { - this.configure() - }, 250)), - - this.hostApp.displayMetricsChanged$.subscribe(() => setTimeout(() => { - this.configure() - }, 250)), + this.hostApp.displayMetricsChanged$.subscribe(maybeConfigure), + this.hostApp.windowMoved$.subscribe(maybeConfigure), ] }