Refuse console input when the terminal is closed

This commit is contained in:
NI
2019-10-01 15:52:43 +08:00
parent 55a1574f46
commit cf6dfaf784

View File

@@ -75,6 +75,7 @@ class Term {
constructor(control) {
const resizeDelayInterval = 500;
this.closed = false;
this.term = new Terminal({
allowTransparency: false,
cursorBlink: true,
@@ -91,10 +92,18 @@ class Term {
});
this.term.onData(data => {
if (this.closed) {
return;
}
control.send(data);
});
this.term.onKey(ev => {
if (this.closed) {
return;
}
if (!control.echo()) {
return;
}
@@ -252,6 +261,8 @@ class Term {
}
destroy() {
this.closed = true;
try {
this.term.dispose();
} catch (e) {