mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-10 19:58:00 +01:00
add initialzing state to deal with quick data
This commit is contained in:
parent
c1b4b7eb63
commit
501e2ac76c
23
src/term.ts
23
src/term.ts
@ -50,6 +50,7 @@ class TermWrap {
|
|||||||
fontSize : number;
|
fontSize : number;
|
||||||
onUpdateContentHeight : (termContext : RendererContext, height : number) => void;
|
onUpdateContentHeight : (termContext : RendererContext, height : number) => void;
|
||||||
ptyDataSource : (termContext : TermContextUnion) => Promise<PtyDataType>;
|
ptyDataSource : (termContext : TermContextUnion) => Promise<PtyDataType>;
|
||||||
|
initializing : boolean;
|
||||||
|
|
||||||
constructor(elem : Element, opts : TermWrapOpts) {
|
constructor(elem : Element, opts : TermWrapOpts) {
|
||||||
opts = opts ?? ({} as any);
|
opts = opts ?? ({} as any);
|
||||||
@ -62,6 +63,7 @@ class TermWrap {
|
|||||||
this.fontSize = opts.fontSize;
|
this.fontSize = opts.fontSize;
|
||||||
this.ptyDataSource = opts.ptyDataSource;
|
this.ptyDataSource = opts.ptyDataSource;
|
||||||
this.onUpdateContentHeight = opts.onUpdateContentHeight;
|
this.onUpdateContentHeight = opts.onUpdateContentHeight;
|
||||||
|
this.initializing = true;
|
||||||
if (this.flexRows) {
|
if (this.flexRows) {
|
||||||
this.atRowMax = false;
|
this.atRowMax = false;
|
||||||
this.usedRows = mobx.observable.box(opts.usedRows ?? (opts.isRunning ? 1 : 0), {name: "term-usedrows"});
|
this.usedRows = mobx.observable.box(opts.usedRows ?? (opts.isRunning ? 1 : 0), {name: "term-usedrows"});
|
||||||
@ -273,13 +275,27 @@ class TermWrap {
|
|||||||
return context.lineNum;
|
return context.lineNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hardResetTerminal() : void {
|
||||||
|
if (this.terminal == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.terminal.reset();
|
||||||
|
this.ptyPos = 0;
|
||||||
|
this.updateUsedRows(true, "term-reset");
|
||||||
|
this.dataUpdates = [];
|
||||||
|
this.numParseErrors = 0;
|
||||||
|
}
|
||||||
|
|
||||||
reload(delayMs : number) {
|
reload(delayMs : number) {
|
||||||
if (this.terminal == null) {
|
if (this.terminal == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// console.log("reload-term", this.getLineNum());
|
// console.log("reload-term", this.getLineNum());
|
||||||
|
if (!this.initializing) {
|
||||||
|
this.hardResetTerminal();
|
||||||
|
}
|
||||||
this.reloading = true;
|
this.reloading = true;
|
||||||
this.terminal.reset();
|
this.initializing = false;
|
||||||
let rtnp = this.ptyDataSource(this.termContext);
|
let rtnp = this.ptyDataSource(this.termContext);
|
||||||
if (rtnp == null) {
|
if (rtnp == null) {
|
||||||
console.log("no promise returned from ptyDataSource (termwrap)", this.termContext);
|
console.log("no promise returned from ptyDataSource (termwrap)", this.termContext);
|
||||||
@ -298,7 +314,10 @@ class TermWrap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
receiveData(pos : number, data : Uint8Array, reason? : string) {
|
receiveData(pos : number, data : Uint8Array, reason? : string) {
|
||||||
// console.log("update-pty-data", reason, this.getLineNum(), data.length, "|", pos, "=>", pos + data.length);
|
// console.log("update-pty-data", reason, "line:" + this.getLineNum(), pos, data.length, "=>", pos + data.length);
|
||||||
|
if (this.initializing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.terminal == null) {
|
if (this.terminal == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user