diff options
Diffstat (limited to 'src/completion.rs')
-rw-r--r-- | src/completion.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/completion.rs b/src/completion.rs index 1d96ce8..a97775e 100644 --- a/src/completion.rs +++ b/src/completion.rs @@ -182,7 +182,7 @@ impl Completion { ) -> FmResult<Vec<String>> { Ok(fs::read_dir(path)? .filter_map(|e| e.ok()) - .filter(|e| e.file_type().unwrap().is_file() && filename_startswith(e, input_string)) + .filter(|e| file_match_input(e, input_string)) .map(|e| e.path().to_string_lossy().into_owned()) .collect()) } @@ -232,6 +232,11 @@ impl Completion { } } +fn file_match_input(dir_entry: &std::fs::DirEntry, input_string: &str) -> bool { + let Ok(file_type) = dir_entry.file_type() else { return false;}; + (file_type.is_file() || file_type.is_symlink()) && filename_startswith(dir_entry, input_string) +} + /// true if the filename starts with a pattern fn filename_startswith(entry: &std::fs::DirEntry, pattern: &str) -> bool { entry |