ipairs refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-11-26 18:28:01 +01:00
parent 90d92ecc34
commit 3f3c7b28fc
9 changed files with 47 additions and 39 deletions
+8 -7
View File
@@ -18,16 +18,16 @@ function M:complete_filter()
local start_index, _, current_modifier = strfind(filter_string, '([^/;]*)$')
current_modifier = current_modifier or ''
for _, suggestion in ipairs(suggestions) do
if strsub(strupper(suggestion), 1, strlen(current_modifier)) == strupper(current_modifier) then
this:SetText(strlower(strsub(filter_string, 1, start_index - 1) .. suggestion))
for i = 1, getn(suggestions) do
if strsub(strupper(suggestions[i]), 1, strlen(current_modifier)) == strupper(current_modifier) then
this:SetText(strlower(strsub(filter_string, 1, start_index - 1) .. suggestions[i]))
this:HighlightText(strlen(filter_string), -1)
return
end
end
end
function M.complete(options)
function M.complete(candidates)
return function(self)
if IsControlKeyDown() then -- TODO problem is ctrl-v, maybe find a better solution
return
@@ -35,9 +35,10 @@ function M.complete(options)
local text = self:GetText()
for _, item_name in ipairs(options()) do
if strsub(strupper(item_name), 1, strlen(text)) == strupper(text) then
self:SetText(strlower(item_name))
local t = temp-candidates()
for i = 1, getn(t) do
if strsub(strupper(t[i]), 1, strlen(text)) == strupper(text) then
self:SetText(strlower(t[i]))
self:HighlightText(strlen(text), -1)
return
end
+4 -3
View File
@@ -340,7 +340,8 @@ function M.query(filter_string)
end
local polish_notation_counter = 0
for _, component in ipairs(filter.post) do
for i = 1, getn(filter.post) do
local component = filter.post[i]
if component[1] == 'operator' then
polish_notation_counter = max(polish_notation_counter, 1)
polish_notation_counter = polish_notation_counter + (tonumber(component[2]) or 1) - 1
@@ -370,8 +371,8 @@ end
function M.queries(filter_string)
local parts = split(filter_string, ';')
local queries = T
for _, str in ipairs(parts) do
str = trim(str)
for i = 1, getn(parts) do
local str = trim(parts[i])
local query, _, error = query(str)
if not query then
return nil, error