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