readline: handle null completer graciously
authorBen Noordhuis <info@bnoordhuis.nl>
Wed, 14 Sep 2011 15:07:58 +0000 (17:07 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Wed, 14 Sep 2011 15:33:07 +0000 (17:33 +0200)
Fixes #1698.

lib/readline.js

index e2b634a279df9117302e255ae815137374671196..6ced9a573e249a9b69cfb2c6ec873f6a804e9328 100644 (file)
@@ -45,6 +45,12 @@ function Interface(input, output, completer) {
   }
   EventEmitter.call(this);
 
+  completer = completer || function() { return []; };
+
+  if (typeof completer !== 'function') {
+    throw new TypeError("Argument 'completer' must be a function");
+  }
+
   var self = this;
 
   this.output = output;
@@ -605,9 +611,7 @@ Interface.prototype._ttyWrite = function(s, key) {
         break;
 
       case 'tab': // tab completion
-        if (this.completer) {
-          this._tabComplete();
-        }
+        this._tabComplete();
         break;
 
       case 'left':