From 96b85d3ee148c4b285455227b951b905fa8f95e2 Mon Sep 17 00:00:00 2001 From: Lennart Kats Date: Wed, 5 Jul 2017 20:35:16 +0000 Subject: [PATCH] Improve debug output --- plugins/c9.ide.terminal/predict_echo.js | 29 ++++++++++++++------ plugins/c9.ide.terminal/predict_echo_test.js | 2 +- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/plugins/c9.ide.terminal/predict_echo.js b/plugins/c9.ide.terminal/predict_echo.js index 867048db..e1b33f6c 100644 --- a/plugins/c9.ide.terminal/predict_echo.js +++ b/plugins/c9.ide.terminal/predict_echo.js @@ -154,13 +154,14 @@ define(function(require, exports, module) { command.after = { predict: predictLine, predictIndex: predictIndex }; command.sent = Date.now(); - DEBUG && console.log("! " - + nonPredictTerminal.$debugCharsAt(nonPredictTerminal.y) - .slice(0, predictStartX) - .map(function(c) { return c || " "; }) - .join("") - + "%c" + predictLine, - "color: lightblue"); + if (DEBUG) { + var alreadyEchoed = predictions[0].before.predict; + console.log("! " + debugPromptSuffix() + + predictLine.substr(0, alreadyEchoed.length) + + "%c" + predictLine.substr(alreadyEchoed.length), + "color: lightblue" + ); + } // DEBUG && console.log("!=" // + 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() { if (!pendingPings.length) return; @@ -208,8 +215,12 @@ define(function(require, exports, module) { DEBUG && console.log( "< " - + (state == STATE_PREDICT ? nonPredictTerminal.$debugCharsAt(e.$startY).join("") + " < " : "") - + e.data + + (state == STATE_PREDICT + ? debugPromptSuffix() + + nonPredictTerminal.$debugCharsAt(e.$startY).slice(predictStartX).join("") + : "") + + "%c < " + e.data, + "color: lightblue" ); if (!predictions.length) { diff --git a/plugins/c9.ide.terminal/predict_echo_test.js b/plugins/c9.ide.terminal/predict_echo_test.js index 3af90267..8b9e2834 100644 --- a/plugins/c9.ide.terminal/predict_echo_test.js +++ b/plugins/c9.ide.terminal/predict_echo_test.js @@ -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 // 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? - editor.ace.onTextInput("PS1='. $ ';" + editor.ace.onTextInput("PS1='P$ ';" + "tmux setw automatic-rename off;" + "printf '\\x1b]0;predict echo\\x07'\n"); // editor.ace.onTextInput("ssh lennart\n");