Improve debug output

pull/449/head
Lennart Kats 2017-07-05 20:35:16 +00:00
rodzic ff501f79f8
commit 96b85d3ee1
2 zmienionych plików z 21 dodań i 10 usunięć

Wyświetl plik

@ -154,13 +154,14 @@ define(function(require, exports, module) {
command.after = { predict: predictLine, predictIndex: predictIndex }; command.after = { predict: predictLine, predictIndex: predictIndex };
command.sent = Date.now(); command.sent = Date.now();
DEBUG && console.log("! " if (DEBUG) {
+ nonPredictTerminal.$debugCharsAt(nonPredictTerminal.y) var alreadyEchoed = predictions[0].before.predict;
.slice(0, predictStartX) console.log("! " + debugPromptSuffix()
.map(function(c) { return c || " "; }) + predictLine.substr(0, alreadyEchoed.length)
.join("") + "%c" + predictLine.substr(alreadyEchoed.length),
+ "%c" + predictLine, "color: lightblue"
"color: lightblue"); );
}
// DEBUG && console.log("!=" // DEBUG && console.log("!="
// + session.terminal.$debugCharsAt(predictStartY - session.terminal.ybase).join("")); // + session.terminal.$debugCharsAt(predictStartY - session.terminal.ybase).join(""));
@ -189,6 +190,12 @@ define(function(require, exports, module) {
} }
} }
function debugPromptSuffix() {
return nonPredictTerminal.$debugCharsAt(nonPredictTerminal.y)
.slice(0, predictStartX).slice(-3)
.map(function(c) { return c || " "; }).join("");
}
function isPossibleConnectionGone() { function isPossibleConnectionGone() {
if (!pendingPings.length) if (!pendingPings.length)
return; return;
@ -208,8 +215,12 @@ define(function(require, exports, module) {
DEBUG && console.log( DEBUG && console.log(
"< " "< "
+ (state == STATE_PREDICT ? nonPredictTerminal.$debugCharsAt(e.$startY).join("") + " < " : "") + (state == STATE_PREDICT
+ e.data ? debugPromptSuffix() +
nonPredictTerminal.$debugCharsAt(e.$startY).slice(predictStartX).join("")
: "")
+ "%c < " + e.data,
"color: lightblue"
); );
if (!predictions.length) { if (!predictions.length) {

Wyświetl plik

@ -143,7 +143,7 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "ace/test/asse
// Make sure we have a prompt with a dollar for tests // Make sure we have a prompt with a dollar for tests
// And terminal won't send rename commands in the middle of the test // And terminal won't send rename commands in the middle of the test
// TODO: do we need to handle rename sequence in predict_echo instead? // TODO: do we need to handle rename sequence in predict_echo instead?
editor.ace.onTextInput("PS1='. $ ';" editor.ace.onTextInput("PS1='P$ ';"
+ "tmux setw automatic-rename off;" + "tmux setw automatic-rename off;"
+ "printf '\\x1b]0;predict echo\\x07'\n"); + "printf '\\x1b]0;predict echo\\x07'\n");
// editor.ace.onTextInput("ssh lennart\n"); // editor.ace.onTextInput("ssh lennart\n");