Fix terminal race condition (afterViewInit vs WS connection)

This commit is contained in:
Kristóf Tóth 2019-08-27 17:20:26 +02:00
parent 00e4c2f7b3
commit 4ac350d665
1 changed files with 6 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import * as terminado from 'xterm/lib/addons/terminado/terminado';
export class TerminadoService {
xterm: Terminal;
ws: WebSocket;
attached = false;
constructor() {
Terminal.applyAddon(fit);
@ -47,6 +48,7 @@ export class TerminadoService {
this.xterm.open(element);
this.fit();
this.xterm.blur();
this.attached = true;
};
}
@ -54,9 +56,12 @@ export class TerminadoService {
(<any>this.xterm).terminadoDetach(this.ws);
this.xterm.destroy();
this.ws.close();
this.attached = false;
}
fit() {
(<any>this.xterm).fit();
if (this.attached) {
(<any>this.xterm).fit();
}
}
}