From 404537f1eb616d6f0c06ebfa4fe71ada85e00fa7 Mon Sep 17 00:00:00 2001 From: Paul Kulchenko Date: Thu, 2 Oct 2014 16:41:16 -0700 Subject: [PATCH] Updated indicator processing to improve performance on large files. --- spec/lua.lua | 2 +- src/editor/editor.lua | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/spec/lua.lua b/spec/lua.lua index ab9d8c1c6e..50b4945470 100644 --- a/spec/lua.lua +++ b/spec/lua.lua @@ -94,7 +94,7 @@ return { local varnext = {} PARSE.parse_scope_resolve(lx, function(op, name, lineinfo, vars) if not(op == 'Id' or op == 'Statement' or op == 'Var' - or op == 'Function' + or op == 'Function' or op == 'String' or op == 'VarNext' or op == 'VarInside' or op == 'VarSelf' or op == 'FunctionCall' or op == 'Scope' or op == 'EndScope') then return end -- "normal" return; not interested in other events diff --git a/src/editor/editor.lua b/src/editor/editor.lua index 096b1743f8..996a19eb3b 100644 --- a/src/editor/editor.lua +++ b/src/editor/editor.lua @@ -528,7 +528,7 @@ function IndicateAll(editor, lines, linee) for n = #tokens, 1, -1 do local token = tokens[n] -- find the last token before the range - if token[1] == 'EndScope' and token.name and token.fpos+#token.name < start then + if token.name and token.fpos+#token.name < start then pos, vars = token.fpos+#token.name, token.context break end @@ -583,7 +583,7 @@ function IndicateAll(editor, lines, linee) local s = TimeGet() local canwork = start and 0.010 or 0.100 -- use shorter interval when typing local f = editor.spec.markvars(editor:GetText(), pos, vars) - + local ops, lastinfo = 0, 0 while true do local op, name, lineinfo, vars, at = f() if not op then break end @@ -597,7 +597,7 @@ function IndicateAll(editor, lines, linee) if indic.fncall and edcfg.showfncall then IndicateOne(indicator.FNCALL, lineinfo, #name) end - elseif op ~= 'VarNext' and op ~= 'VarInside' and op ~= 'Statement' then + elseif op ~= 'VarNext' and op ~= 'VarInside' and op ~= 'Statement' and op ~= 'String' then table.insert(tokens, token) end @@ -619,10 +619,11 @@ function IndicateAll(editor, lines, linee) if indic.varmasking then IndicateOne(indicator.MASKING, lineinfo, #name) end end - if op == 'EndScope' and name and TimeGet()-s > canwork then - delayed[editor] = {lineinfo+#name, vars} + if lineinfo and lineinfo > lastinfo and ops % 10 == 0 and TimeGet()-s > canwork then + delayed[editor] = {lineinfo, vars} break end + lastinfo = lineinfo or lastinfo end -- clear indicators till the end of processed fragment