make filter case insensitive

This commit is contained in:
Lilian Jónsdóttir 2024-07-30 18:53:44 -07:00
parent 1403f2e62f
commit 48844886a9

View file

@ -594,7 +594,7 @@ func (m *model) applyFilter() {
func (m *model) filteredFiles() (filteredFiles files.Files) {
for _, file := range m.files {
if fuzzy.Match(m.filter, file.Name()) {
if isMatch(m.filter, file.Name()) {
filteredFiles = append(filteredFiles, file)
} else {
if _, ok := m.selected[file.String()]; ok {
@ -704,3 +704,9 @@ func makeUnselectedStyle() table.Styles {
func styleKey(key key.Binding) string {
return fmt.Sprintf("%s %s", darktext.Render(key.Help().Key), darkertext.Render(key.Help().Desc))
}
func isMatch(pattern, filename string) bool {
p := strings.ToLower(pattern)
f := strings.ToLower(filename)
return fuzzy.Match(p, f)
}