kopia lustrzana https://github.com/c9/core
Fix initialization with multiple terminals
rodzic
3804feb7b9
commit
50b131f156
|
@ -71,6 +71,9 @@ define(function(require, exports, module) {
|
||||||
terminal.on("beforeWrite", function(e) {
|
terminal.on("beforeWrite", function(e) {
|
||||||
return e.session.$predictor.onBeforeWrite(e);
|
return e.session.$predictor.onBeforeWrite(e);
|
||||||
}, plugin);
|
}, plugin);
|
||||||
|
terminal.on("afterWrite", function(e) {
|
||||||
|
return e.session.$predictor.onAfterWrite(e);
|
||||||
|
}, plugin);
|
||||||
terminal.on("input", function(e) {
|
terminal.on("input", function(e) {
|
||||||
DEBUG && console.log(">", e.data.replace("\r", "\\r").replace("\u007F", "\\bs"));
|
DEBUG && console.log(">", e.data.replace("\r", "\\r").replace("\u007F", "\\bs"));
|
||||||
return e.session.$predictor.onInput(e);
|
return e.session.$predictor.onInput(e);
|
||||||
|
@ -492,28 +495,33 @@ define(function(require, exports, module) {
|
||||||
if (lastInput
|
if (lastInput
|
||||||
&& (state === STATE_WAIT_FOR_PROMPT_OR_ECHO)
|
&& (state === STATE_WAIT_FOR_PROMPT_OR_ECHO)
|
||||||
&& lastInput === data.substr(data.length - lastInput.length)
|
&& lastInput === data.substr(data.length - lastInput.length)
|
||||||
&& (!BASH_ONLY || isBashActive())) {
|
&& (!BASH_ONLY || isBashActive())
|
||||||
|
&& checkTextBeforePrediction()) {
|
||||||
if (DEBUG) console.log(" ^ re-enabled predictions:", lastInput);
|
if (DEBUG) console.log(" ^ re-enabled predictions:", lastInput);
|
||||||
return startPredict();
|
return startPredict();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function startPredict() {
|
function startPredict() {
|
||||||
state = STATE_INITING;
|
|
||||||
predictIndex = 0;
|
predictIndex = 0;
|
||||||
predictLine = "";
|
predictLine = "";
|
||||||
predictStartX = nonPredictTerminal.x;
|
predictStartX = nonPredictTerminal.x;
|
||||||
nonPredictStartY = nonPredictTerminal.y + nonPredictTerminal.ybase;
|
nonPredictStartY = nonPredictTerminal.y + nonPredictTerminal.ybase;
|
||||||
predictStartY = session.terminal.y + session.terminal.ybase;
|
predictStartY = session.terminal.y + session.terminal.ybase;
|
||||||
terminal.once("afterWrite", function() {
|
state = STATE_INITING;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onAfterWrite(e) {
|
||||||
|
if (state !== STATE_INITING)
|
||||||
|
return;
|
||||||
|
|
||||||
predictStartY = session.terminal.y + session.terminal.ybase;
|
predictStartY = session.terminal.y + session.terminal.ybase;
|
||||||
state = STATE_PREDICT;
|
state = STATE_PREDICT;
|
||||||
if (!checkTextBeforePrediction()) {
|
if (!checkTextBeforePrediction()) {
|
||||||
// Appears to happen when tmux or shell unexpectedly sends a new line
|
// Appears to happen when tmux or shell unexpectedly sends a new line
|
||||||
console.warn("Unable to init predictions");
|
console.log("[predict_echo] Unable to init predictions; will try again later");
|
||||||
state = STATE_WAIT_FOR_ECHO;
|
state = STATE_WAIT_FOR_PROMPT;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isBashActive() {
|
function isBashActive() {
|
||||||
|
@ -736,7 +744,8 @@ define(function(require, exports, module) {
|
||||||
get predictions() { return predictions; },
|
get predictions() { return predictions; },
|
||||||
undoPredictions: undoPredictions,
|
undoPredictions: undoPredictions,
|
||||||
onInput: onInput,
|
onInput: onInput,
|
||||||
onBeforeWrite: onBeforeWrite
|
onBeforeWrite: onBeforeWrite,
|
||||||
|
onAfterWrite: onAfterWrite,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue