mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 19:22:25 +01:00
Cache the parse stack in JS completion again.
This commit is contained in:
@@ -628,7 +628,7 @@ function Completion() //{{{
|
|||||||
return a[a.length - m - 1];
|
return a[a.length - m - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildStack(start)
|
function buildStack(filter)
|
||||||
{
|
{
|
||||||
let self = this;
|
let self = this;
|
||||||
/* Push and pop the stack, maintaining references to 'top' and 'last'. */
|
/* Push and pop the stack, maintaining references to 'top' and 'last'. */
|
||||||
@@ -661,15 +661,26 @@ function Completion() //{{{
|
|||||||
|
|
||||||
let i = 0, c = ""; /* Current index and character, respectively. */
|
let i = 0, c = ""; /* Current index and character, respectively. */
|
||||||
|
|
||||||
|
// Reuse the old stack.
|
||||||
|
if (str && filter.substr(0, str.length) == str)
|
||||||
|
{
|
||||||
|
i = str.length;
|
||||||
|
if (this.popStatement)
|
||||||
|
top[STATEMENTS].pop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
stack = [];
|
stack = [];
|
||||||
functions = [];
|
functions = [];
|
||||||
push("#root");
|
push("#root");
|
||||||
|
}
|
||||||
|
|
||||||
/* Build a parse stack, discarding entries as opening characters
|
/* Build a parse stack, discarding entries as opening characters
|
||||||
* match closing characters. The stack is walked from the top entry
|
* match closing characters. The stack is walked from the top entry
|
||||||
* and down as many levels as it takes us to figure out what it is
|
* and down as many levels as it takes us to figure out what it is
|
||||||
* that we're completing.
|
* that we're completing.
|
||||||
*/
|
*/
|
||||||
|
str = filter;
|
||||||
let length = str.length;
|
let length = str.length;
|
||||||
for (; i < length; lastChar = c, i++)
|
for (; i < length; lastChar = c, i++)
|
||||||
{
|
{
|
||||||
@@ -733,8 +744,12 @@ function Completion() //{{{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.popStatement = false;
|
||||||
if (!/[\w\d$]/.test(lastChar) && lastNonwhite != ".")
|
if (!/[\w\d$]/.test(lastChar) && lastNonwhite != ".")
|
||||||
|
{
|
||||||
|
this.popStatement = true;
|
||||||
top[STATEMENTS].push(i);
|
top[STATEMENTS].push(i);
|
||||||
|
}
|
||||||
|
|
||||||
lastIdx = i;
|
lastIdx = i;
|
||||||
}
|
}
|
||||||
@@ -742,13 +757,11 @@ function Completion() //{{{
|
|||||||
this.complete = function _complete(context)
|
this.complete = function _complete(context)
|
||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
let string = context.filter;
|
|
||||||
|
|
||||||
let self = this;
|
let self = this;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
str = string;
|
buildStack.call(this, context.filter);
|
||||||
buildStack.call(this);
|
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user