diff --git a/lib/coffee-script/repl.js b/lib/coffee-script/repl.js index 437088a6..0a24e352 100644 --- a/lib/coffee-script/repl.js +++ b/lib/coffee-script/repl.js @@ -75,10 +75,21 @@ } }; completeVariable = function(text) { - var completions, free, possibilities, vars, _ref; - if (free = (_ref = text.match(SIMPLEVAR)) != null ? _ref[1] : void 0) { + var completions, free, keywords, possibilities, r, vars, _ref; + free = (_ref = text.match(SIMPLEVAR)) != null ? _ref[1] : void 0; + if (free != null) { vars = Script.runInContext('Object.getOwnPropertyNames(this)', sandbox); - possibilities = vars.concat(CoffeeScript.RESERVED); + keywords = (function() { + var _j, _len2, _ref2, _results; + _ref2 = CoffeeScript.RESERVED; + _results = []; + for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { + r = _ref2[_j]; + if (r.slice(0, 2) !== '__') _results.push(r); + } + return _results; + })(); + possibilities = vars.concat(keywords); completions = getCompletions(free, possibilities); return [completions, free]; } diff --git a/src/repl.coffee b/src/repl.coffee index 06659c6e..a29a2398 100644 --- a/src/repl.coffee +++ b/src/repl.coffee @@ -94,9 +94,11 @@ completeAttribute = (text) -> # Attempt to autocomplete an in-scope free variable: `one`. completeVariable = (text) -> - if free = (text.match SIMPLEVAR)?[1] + free = (text.match SIMPLEVAR)?[1] + if free? vars = Script.runInContext 'Object.getOwnPropertyNames(this)', sandbox - possibilities = vars.concat CoffeeScript.RESERVED + keywords = (r for r in CoffeeScript.RESERVED when r[0..1] isnt '__') + possibilities = vars.concat keywords completions = getCompletions free, possibilities [completions, free]