mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 11:58:00 +01:00
Add "Global Variables" section to JS completion for the eval context.
This commit is contained in:
@@ -573,7 +573,7 @@ function Completion() //{{{
|
|||||||
|
|
||||||
// v[0] in orig and orig[v[0]] catch different cases. XPCOM
|
// v[0] in orig and orig[v[0]] catch different cases. XPCOM
|
||||||
// objects are problematic, to say the least.
|
// objects are problematic, to say the least.
|
||||||
if (obj.__proto__ == modules || obj.__proto__ == plugins) // Special case.
|
if ([modules, plugins, userContext].some(function (o) o.isPrototypeOf(obj)))
|
||||||
compl = [v for (v in Iterator(obj))];
|
compl = [v for (v in Iterator(obj))];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -790,7 +790,7 @@ function Completion() //{{{
|
|||||||
|
|
||||||
let cache = this.context.cache;
|
let cache = this.context.cache;
|
||||||
this.context.getCache("eval", Object);
|
this.context.getCache("eval", Object);
|
||||||
this.context.getCache("evalContext", function () ({ __proto__: modules }));
|
this.context.getCache("evalContext", function () ({ __proto__: userContext }));
|
||||||
|
|
||||||
/* Okay, have parse stack. Figure out what we're completing. */
|
/* Okay, have parse stack. Figure out what we're completing. */
|
||||||
|
|
||||||
@@ -839,7 +839,6 @@ function Completion() //{{{
|
|||||||
|
|
||||||
if (prev != statement)
|
if (prev != statement)
|
||||||
s = EVAL_TMP + "." + s;
|
s = EVAL_TMP + "." + s;
|
||||||
liberator.dump("s : " + s);
|
|
||||||
cacheKey = str.substring(statement, dot);
|
cacheKey = str.substring(statement, dot);
|
||||||
|
|
||||||
if (checkFunction(prev, dot, cacheKey))
|
if (checkFunction(prev, dot, cacheKey))
|
||||||
@@ -858,7 +857,8 @@ function Completion() //{{{
|
|||||||
let end = (frame == -1 ? lastIdx : get(frame + 1)[OFFSET]);
|
let end = (frame == -1 ? lastIdx : get(frame + 1)[OFFSET]);
|
||||||
|
|
||||||
cacheKey = null;
|
cacheKey = null;
|
||||||
let obj = [[cache.evalContext, "Local Variables"], [modules, "modules"], [window, "window"]]; // Default objects;
|
let obj = [[cache.evalContext, "Local Variables"], [userContext, "Global Variables"],
|
||||||
|
[modules, "modules"], [window, "window"]]; // Default objects;
|
||||||
/* Is this an object dereference? */
|
/* Is this an object dereference? */
|
||||||
if (dot < statement) // No.
|
if (dot < statement) // No.
|
||||||
dot = statement - 1;
|
dot = statement - 1;
|
||||||
@@ -906,6 +906,8 @@ function Completion() //{{{
|
|||||||
}
|
}
|
||||||
if (!context.anchored) // We've already listed anchored matches, so don't list them again here.
|
if (!context.anchored) // We've already listed anchored matches, so don't list them again here.
|
||||||
context.filters.push(function (item) util.compareIgnoreCase(item.text.substr(0, this.filter.length), this.filter));
|
context.filters.push(function (item) util.compareIgnoreCase(item.text.substr(0, this.filter.length), this.filter));
|
||||||
|
if (obj == cache.evalContext)
|
||||||
|
context.regenerate = true;
|
||||||
context.generate = function () self.objectKeys(obj);
|
context.generate = function () self.objectKeys(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user