mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
fixes #1976: minor REPL tab completion bug fixes
This commit is contained in:
@@ -62,7 +62,7 @@
|
||||
|
||||
ACCESSOR = /\s*([\w\.]+)(?:\.(\w*))$/;
|
||||
|
||||
SIMPLEVAR = /\s*(\w*)$/i;
|
||||
SIMPLEVAR = /(\w+)$/i;
|
||||
|
||||
autocomplete = function(text) {
|
||||
return completeAttribute(text) || completeVariable(text) || [[], text];
|
||||
@@ -77,7 +77,7 @@
|
||||
} catch (error) {
|
||||
return;
|
||||
}
|
||||
completions = getCompletions(prefix, Object.getOwnPropertyNames(val));
|
||||
completions = getCompletions(prefix, Object.getOwnPropertyNames(Object(val)));
|
||||
return [completions, prefix];
|
||||
}
|
||||
};
|
||||
@@ -85,8 +85,9 @@
|
||||
completeVariable = function(text) {
|
||||
var completions, free, keywords, possibilities, r, vars, _ref;
|
||||
free = (_ref = text.match(SIMPLEVAR)) != null ? _ref[1] : void 0;
|
||||
if (text === "") free = "";
|
||||
if (free != null) {
|
||||
vars = Script.runInThisContext('Object.getOwnPropertyNames(this)');
|
||||
vars = Script.runInThisContext('Object.getOwnPropertyNames(Object(this))');
|
||||
keywords = (function() {
|
||||
var _i, _len, _ref2, _results;
|
||||
_ref2 = CoffeeScript.RESERVED;
|
||||
|
||||
@@ -63,7 +63,7 @@ run = (buffer) ->
|
||||
|
||||
# Regexes to match complete-able bits of text.
|
||||
ACCESSOR = /\s*([\w\.]+)(?:\.(\w*))$/
|
||||
SIMPLEVAR = /\s*(\w*)$/i
|
||||
SIMPLEVAR = /(\w+)$/i
|
||||
|
||||
# Returns a list of completions, and the completed text.
|
||||
autocomplete = (text) ->
|
||||
@@ -77,14 +77,15 @@ completeAttribute = (text) ->
|
||||
val = Script.runInThisContext obj
|
||||
catch error
|
||||
return
|
||||
completions = getCompletions prefix, Object.getOwnPropertyNames val
|
||||
completions = getCompletions prefix, Object.getOwnPropertyNames Object val
|
||||
[completions, prefix]
|
||||
|
||||
# Attempt to autocomplete an in-scope free variable: `one`.
|
||||
completeVariable = (text) ->
|
||||
free = (text.match SIMPLEVAR)?[1]
|
||||
free = text.match(SIMPLEVAR)?[1]
|
||||
free = "" if text is ""
|
||||
if free?
|
||||
vars = Script.runInThisContext 'Object.getOwnPropertyNames(this)'
|
||||
vars = Script.runInThisContext 'Object.getOwnPropertyNames(Object(this))'
|
||||
keywords = (r for r in CoffeeScript.RESERVED when r[..1] isnt '__')
|
||||
possibilities = vars.concat keywords
|
||||
completions = getCompletions free, possibilities
|
||||
|
||||
Reference in New Issue
Block a user