From c1b9de87d2303acecd763d71c020d70046049dc8 Mon Sep 17 00:00:00 2001 From: Robob27 Date: Mon, 6 Feb 2023 22:40:59 -0500 Subject: [PATCH] Add case_sensitive attr to FilteredList --- library/lua/gui/widgets.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/library/lua/gui/widgets.lua b/library/lua/gui/widgets.lua index d8c605b93..61cd92cfa 100644 --- a/library/lua/gui/widgets.lua +++ b/library/lua/gui/widgets.lua @@ -1866,6 +1866,7 @@ end FilteredList = defclass(FilteredList, Widget) FilteredList.ATTRS { + case_sensitive = true, edit_below = false, edit_key = DEFAULT_NIL, edit_ignore_keys = DEFAULT_NIL, @@ -2026,11 +2027,17 @@ function FilteredList:setFilter(filter, pos) -- start matches at non-space or non-punctuation. this allows -- punctuation itself to be matched if that is useful (e.g. -- filenames or parameter names) - if key ~= '' and + if key ~= '' then + if self.case_sensitive and not search_key:match('%f[^%p\x00]'..key) and not search_key:match('%f[^%s\x00]'..key) then - ok = false - break + ok = false + break + elseif not string.lower(search_key):match('%f[^%p\x00]'..string.lower(key)) and + not string.lower(search_key):match('%f[^%s\x00]'..string.lower(key)) then + ok = false + break + end end end if ok then