Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Commit

Permalink
Fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
kilbith committed Apr 23, 2022
1 parent 7e0feef commit 312da62
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions src/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,44 +101,47 @@ local function search(data)
for i = 1, #data.items_raw do
local item = data.items_raw[i]
local def = reg_items[item]
local desc = lower(translate(data.lang_code, def and def.description)) or ""
local search_in = fmt("%s %s", item, desc)
local temp, j, to_add = {}, 1

if search_filter then
for filter_name, values in pairs(filters) do
if values then
local func = i3.search_filters[filter_name]
to_add = (j > 1 and temp[item] or j == 1) and
func(item, values) and (search_filter == "" or
find(search_in, search_filter, 1, true))

if to_add then
temp[item] = true

if def then
local desc = lower(translate(data.lang_code, def and def.description)) or ""
local search_in = fmt("%s %s", item, desc)
local temp, j, to_add = {}, 1

if search_filter then
for filter_name, values in pairs(filters) do
if values then
local func = i3.search_filters[filter_name]
to_add = (j > 1 and temp[item] or j == 1) and
func(item, values) and (search_filter == "" or
find(search_in, search_filter, 1, true))

if to_add then
temp[item] = true
end

j++
end
end
else
local ok = true

j++
for keyword in gmatch(filter, "%S+") do
if not find(search_in, keyword, 1, true) then
ok = nil
break
end
end
end
else
local ok = true

for keyword in gmatch(filter, "%S+") do
if not find(search_in, keyword, 1, true) then
ok = nil
break
if ok then
to_add = true
end
end

if ok then
to_add = true
if to_add then
c++
filtered_list[c] = item
end
end

if to_add then
c++
filtered_list[c] = item
end
end

data.items = filtered_list
Expand Down

0 comments on commit 312da62

Please sign in to comment.