Merge remote branch 'origin/v0.4'
authorRyan Dahl <ry@tinyclouds.org>
Thu, 15 Sep 2011 18:47:33 +0000 (11:47 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Thu, 15 Sep 2011 18:48:37 +0000 (11:48 -0700)
Conflicts:
deps/http_parser/http_parser.c
deps/http_parser/test.c
lib/repl.js

1  2 
lib/module.js
lib/repl.js

diff --cc lib/module.js
Simple merge
diff --cc lib/repl.js
@@@ -487,50 -430,43 +495,50 @@@ REPLServer.prototype.complete = functio
      }
    }
  
 -  // Filter, sort (within each group), uniq and merge the completion groups.
 -  if (completionGroups.length && filter) {
 -    var newCompletionGroups = [];
 -    for (i = 0; i < completionGroups.length; i++) {
 -      group = completionGroups[i].filter(function(elem) {
 -        return elem.indexOf(filter) == 0;
 -      });
 -      if (group.length) {
 -        newCompletionGroups.push(group);
 +  // Will be called when all completionGroups are in place
 +  // Useful for async autocompletion
 +  function completionGroupsLoaded(err) {
 +    if (err) throw err;
 +
 +    // Filter, sort (within each group), uniq and merge the completion groups.
 +    if (completionGroups.length && filter) {
 +      var newCompletionGroups = [];
 +      for (i = 0; i < completionGroups.length; i++) {
 +        group = completionGroups[i].filter(function(elem) {
 +          return elem.indexOf(filter) == 0;
 +        });
 +        if (group.length) {
 +          newCompletionGroups.push(group);
 +        }
        }
 +      completionGroups = newCompletionGroups;
      }
 -    completionGroups = newCompletionGroups;
 -  }
  
 -  if (completionGroups.length) {
 -    var uniq = {};  // unique completions across all groups
 -    completions = [];
 -    // Completion group 0 is the "closest" (least far up the inheritance chain)
 -    // so we put its completions last: to be closest in the REPL.
 -    for (i = completionGroups.length - 1; i >= 0; i--) {
 -      group = completionGroups[i];
 -      group.sort();
 -      for (var j = 0; j < group.length; j++) {
 -        c = group[j];
 -        if (!hasOwnProperty(uniq, c)) {
 -          completions.push(c);
 -          uniq[c] = true;
 +    if (completionGroups.length) {
 +      var uniq = {};  // unique completions across all groups
 +      completions = [];
 +      // Completion group 0 is the "closest"
 +      // (least far up the inheritance chain)
 +      // so we put its completions last: to be closest in the REPL.
 +      for (i = completionGroups.length - 1; i >= 0; i--) {
 +        group = completionGroups[i];
 +        group.sort();
 +        for (var j = 0; j < group.length; j++) {
 +          c = group[j];
-           if (!uniq.hasOwnProperty(c)) {
++          if (!hasOwnProperty(c)) {
 +            completions.push(c);
 +            uniq[c] = true;
 +          }
          }
 +        completions.push(''); // separator btwn groups
 +      }
 +      while (completions.length && completions[completions.length - 1] === '') {
 +        completions.pop();
        }
 -      completions.push(''); // separator btwn groups
 -    }
 -    while (completions.length && completions[completions.length - 1] === '') {
 -      completions.pop();
      }
 -  }
  
 -  return [completions || [], completeOn];
 +    callback(null, [completions || [], completeOn]);
 +  }
  };