diff --git a/lib/coffee-script/repl.js b/lib/coffee-script/repl.js index c8e76eaa..f47bfef1 100644 --- a/lib/coffee-script/repl.js +++ b/lib/coffee-script/repl.js @@ -41,7 +41,7 @@ }; completeAttribute = function(text) { - var all, completions, key, match, obj, prefix, val; + var all, completions, key, match, obj, possibilities, prefix, val; if (match = text.match(ACCESSOR)) { all = match[0], obj = match[1], prefix = match[2]; try { @@ -49,14 +49,14 @@ } catch (error) { return; } - completions = getCompletions(prefix, (function() { - var _results; - _results = []; - for (key in Object(val)) { - _results.push(key); + val = Object(val); + possibilities = Object.getOwnPropertyNames(val); + for (key in val) { + if (~possibilities.indexOf(val)) { + possibilities.push(key); } - return _results; - })()); + } + completions = getCompletions(prefix, possibilities); return [completions, prefix]; } }; diff --git a/src/repl.coffee b/src/repl.coffee index b5e24b9e..5b959560 100644 --- a/src/repl.coffee +++ b/src/repl.coffee @@ -47,7 +47,11 @@ completeAttribute = (text) -> val = Script.runInThisContext obj catch error return - completions = getCompletions prefix, (key for key of Object(val)) + val = Object val + possibilities = Object.getOwnPropertyNames val + for key of val when ~possibilities.indexOf val + possibilities.push key + completions = getCompletions prefix, possibilities [completions, prefix] # Attempt to autocomplete an in-scope free variable: `one`.