repl: allowing tab completion of an empty line and masking `__X`
reserved helpers from tab completion; fixes #1583
This commit is contained in:
parent
818216374c
commit
13ac72239a
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
|
Loading…
Reference in New Issue