Skip to main content

putzen_cli/caches/tui/
filter.rs

1//! `/`-style substring filter applied to the left list.
2
3/// Less/vim-style `/` filter applied to the left list. When `Modal::FilterEdit`
4/// is active the input strip is open and printable keys are routed to it; when
5/// not, the filter is "applied" — rows still hidden, but the strip shows
6/// the static badge.
7#[derive(Debug, Clone, Default, PartialEq, Eq)]
8pub struct Filter {
9    pub input: String,
10}
11
12impl Filter {
13    /// True when the row's absolute path contains the (case-insensitive)
14    /// filter substring. Empty input matches everything.
15    pub fn is_visible(&self, path: &std::path::Path) -> bool {
16        if self.input.is_empty() {
17            return true;
18        }
19        let needle = self.input.to_lowercase();
20        let hay = path.to_string_lossy().to_lowercase();
21        hay.contains(&needle)
22    }
23}