-
Notifications
You must be signed in to change notification settings - Fork 25
Added tab completion functionality for collections #337
base: master
Are you sure you want to change the base?
Conversation
var cur = editor.getCursor(); | ||
var token = editor.getTokenAt(cur); | ||
var tprop = token; | ||
if (/\b(?:string|comment)\b/.test(token.type)) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment explaining what this regex is matching? if it is matches "string" or "comment" why do we return?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes its matching either string or comment. I will modify this to be more clear by removing the regex altogether.
You're right it shouldn't be returning, it should be calling the callback with no autocompletions in it and then returning. Good catch. The intent of the returning is that there are no autocompletion results to present if we are in a comment or string
This looks pretty exciting, but I don't fully understand it. I'd like to get on a call to walk through it when you have time. |
…y caching the results of ajax call
show-hint.js
add-on.Assume that the collections
foo
,bar
, andfoobar
exist.After hitting tab,
db.
will autocomplete to show all of the above optionsdb.f
will autocomplete to showfoo
andfoobar
db.foob
will autocomplete automatically tofoobar
Furthermore,
if
x=db
has been executed previously,x.
will also autocomplete to show all of the available optionsBut if
y = {}
has been executed,y.
will not autocomplete because it does not evaluate to an object equal to the globaldb
object.Finally, if we set:
a = {}
a.b = db
Then the autocompletion logic will recognize that
a.b
evaluates todb
and therefore will autocompletea.b.
to all of the available options.For now, this context-awareness only works for properties in dot-notation, but I plan on implementing it for bracket notation as well (which is really just a special type of property access). Evaluating functions is more problematic, however, because there is no way to safely know which function evaluations will modify state and which ones won't.