Add case_sensitive attr to FilteredList

develop
Robob27 2023-02-06 22:40:59 -05:00
parent df5184d751
commit c1b9de87d2
1 changed files with 10 additions and 3 deletions

@ -1866,6 +1866,7 @@ end
FilteredList = defclass(FilteredList, Widget) FilteredList = defclass(FilteredList, Widget)
FilteredList.ATTRS { FilteredList.ATTRS {
case_sensitive = true,
edit_below = false, edit_below = false,
edit_key = DEFAULT_NIL, edit_key = DEFAULT_NIL,
edit_ignore_keys = 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 -- start matches at non-space or non-punctuation. this allows
-- punctuation itself to be matched if that is useful (e.g. -- punctuation itself to be matched if that is useful (e.g.
-- filenames or parameter names) -- 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[^%p\x00]'..key) and
not search_key:match('%f[^%s\x00]'..key) then not search_key:match('%f[^%s\x00]'..key) then
ok = false ok = false
break 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
end end
if ok then if ok then