Fixes #2280 -- add enumerable prototypal properties to autocompletion.

This commit is contained in:
Jeremy Ashkenas 2012-04-24 16:26:07 -04:00
parent e433098eb2
commit 8bc6001d27
2 changed files with 10 additions and 3 deletions

View File

@ -41,7 +41,7 @@
};
completeAttribute = function(text) {
var all, completions, match, obj, prefix, val;
var all, completions, key, match, obj, prefix, val;
if (match = text.match(ACCESSOR)) {
all = match[0], obj = match[1], prefix = match[2];
try {
@ -49,7 +49,14 @@
} catch (error) {
return;
}
completions = getCompletions(prefix, Object.getOwnPropertyNames(Object(val)));
completions = getCompletions(prefix, (function() {
var _results;
_results = [];
for (key in Object(val)) {
_results.push(key);
}
return _results;
})());
return [completions, prefix];
}
};

View File

@ -47,7 +47,7 @@ completeAttribute = (text) ->
val = Script.runInThisContext obj
catch error
return
completions = getCompletions prefix, Object.getOwnPropertyNames Object val
completions = getCompletions prefix, (key for key of Object(val))
[completions, prefix]
# Attempt to autocomplete an in-scope free variable: `one`.