diff options
author | Justin Chen <ctj12461@163.com> | 2023-08-13 23:12:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-13 11:12:59 -0400 |
commit | 7ab12658f911bebfa12f836b2a6449e08611e437 (patch) | |
tree | c5b00ec5342ff424b05d0f3c1dd283115c73bceb /src/commands/filter.rs | |
parent | 82e231ac004e1f25f0a447bc601e5e3a10dca4d2 (diff) |
feat: Add case sensitivity support for searching, selecting and filtering files (#393)
* feat: Add struct and enum definitons for choosing case sensitivity of search
* feat: Implement `FromStr` for CaseSensitivity
* feat: Add a command to change the configuration of case sensitivity
* feat: Add case sensitivity support for search operations
* feat: Add case sensitivity support for selection operations
* docs: Add explanations for the new feature
* feat: Add case sensitivity support for searching with fzf
* docs: Add explanations for the new feature
* docs: Update documents
* feat: Refactor and add case sensitivity support for the filter operation
* refactor: Extract codes related to constructing the context for searching
* refactor: Extract the common component of searching, selecting and filtering files
* refactor: Change the module path and name
* feat: Use separate options for case sensitivity configurations
* feat: Add support for changing case sensitivity configurations at runtime
* docs: Add explanations for the new command
Diffstat (limited to 'src/commands/filter.rs')
-rw-r--r-- | src/commands/filter.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/commands/filter.rs b/src/commands/filter.rs index 2ea818d..fbf1d30 100644 --- a/src/commands/filter.rs +++ b/src/commands/filter.rs @@ -1,15 +1,23 @@ -use crate::context::AppContext; +use crate::context::{AppContext, MatchContext}; use crate::error::JoshutoResult; use super::reload; -pub fn filter(context: &mut AppContext, arg: &str) -> JoshutoResult { +pub fn filter(context: &mut AppContext, pattern: &str) -> JoshutoResult { + let case_sensitivity = context + .config_ref() + .search_options_ref() + .string_case_sensitivity; + + let filter_context = MatchContext::new_string(pattern, case_sensitivity); + let curr_tab = context.tab_context_mut().curr_tab_mut(); let path = curr_tab.cwd().to_path_buf(); + curr_tab .option_mut() .dirlist_options_mut(&path) - .set_filter_string(arg); + .set_filter_context(filter_context); if let Some(list) = curr_tab.curr_list_mut() { list.depreciate(); |