From: Ryan Dahl Date: Thu, 15 Sep 2011 18:47:33 +0000 (-0700) Subject: Merge remote branch 'origin/v0.4' X-Git-Tag: v0.5.7~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a1bafc55665e9fe17c831ca23193cf51027af776;p=platform%2Fupstream%2Fnodejs.git Merge remote branch 'origin/v0.4' Conflicts: deps/http_parser/http_parser.c deps/http_parser/test.c lib/repl.js --- a1bafc55665e9fe17c831ca23193cf51027af776 diff --cc lib/repl.js index 27eeaf5,3ae5b4c..347f7a0 --- a/lib/repl.js +++ b/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]); + } };