diff --git a/plugins/c9.ide.terminal/predict_echo.js b/plugins/c9.ide.terminal/predict_echo.js index 6e40b44b..00be29f0 100644 --- a/plugins/c9.ide.terminal/predict_echo.js +++ b/plugins/c9.ide.terminal/predict_echo.js @@ -408,6 +408,10 @@ define(function(require, exports, module) { // No matches. Return if our predictions were optional. if (isOptionalOnly(predictions)) return done(null, []); + + // No matches. But it seems we got a noop input. Our predictions likely happen later. + if (matchPrediction(new NoopCommand())) + return done(null, []); // No matches for our predictions :( We likely made a mistake. // Reporting false here ensures we catch mistakes early. @@ -700,6 +704,26 @@ define(function(require, exports, module) { }; } + /** + * Noop command. Factory method: tryCreate(). + */ + NoopCommand.tryCreate = function() { + var result = new NoopCommand(); + result.before = { predict: predictLine, predictIndex: predictIndex }; + result.after = { predict: predictLine, predictIndex: predictIndex }; + return result; + }; + function NoopCommand() { + var outputText = predictIndex ? getCursorLeft(predictIndex) : ""; + return { + $outputText: outputText, + do: function() { + echo(outputText); + predictIndex = 0; + } + }; + } + // Predictor API return { get state() { return state; },