properly recover tabs with xterm

This commit is contained in:
Eugene Pankov
2019-01-27 22:01:55 +01:00
parent fab21f6859
commit 792de65696
4 changed files with 21 additions and 4 deletions

View File

@@ -145,7 +145,15 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
})
this.frontend.configure()
this.frontend.attach(this.content.nativeElement)
if (this.hasFocus) {
this.frontend.attach(this.content.nativeElement)
} else {
this.focused$.pipe(first()).subscribe(() => {
this.frontend.attach(this.content.nativeElement)
})
}
this.attachTermContainerHandlers()
this.configure()

View File

@@ -54,6 +54,14 @@ export class XTermFrontend extends Frontend {
this.xtermCore._scrollToBottom = this.xtermCore.scrollToBottom.bind(this.xtermCore)
this.xtermCore.scrollToBottom = () => null
this.resizeHandler = () => {
try {
(this.xterm as any).fit()
} catch {
// tends to throw when element wasn't shown yet
}
}
}
attach (host: HTMLElement): void {
@@ -61,7 +69,6 @@ export class XTermFrontend extends Frontend {
this.ready.next(null)
this.ready.complete()
this.resizeHandler = () => (this.xterm as any).fit()
window.addEventListener('resize', this.resizeHandler)
this.resizeHandler()