Consider match success if input seemed to be a noop

pull/449/head
Lennart Kats 2017-07-05 14:41:15 +00:00
rodzic bfd5aa7f44
commit a734df504e
1 zmienionych plików z 24 dodań i 0 usunięć

Wyświetl plik

@ -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; },