diff --git a/widget/app_launcher/init.lua b/widget/app_launcher/init.lua index 61a7f40..53a1901 100644 --- a/widget/app_launcher/init.lua +++ b/widget/app_launcher/init.lua @@ -71,24 +71,9 @@ local function string_levenshtein(str1, str2) return matrix[len1][len2] end -local function case_insensitive_pattern(pattern) - -- find an optional '%' (group 1) followed by any character (group 2) - local p = pattern:gsub("(%%?)(.)", function(percent, letter) - if percent ~= "" or not letter:match("%a") then - -- if the '%' matched, or `letter` is not a letter, return "as is" - return percent .. letter - else - -- else, return a case-insensitive character class of the matched letter - return string.format("[%s%s]", letter:lower(), letter:upper()) - end - end) - - return p -end - local function has_value(tab, val) - for index, value in pairs(tab) do - if val:find(case_insensitive_pattern(value)) then + for _, value in ipairs(tab) do + if val:lower():find(value:lower(), 1, true) then return true end end