aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel S Poulin2021-10-22 01:02:05 +0000
committerGitHub2021-10-22 01:02:05 +0000
commit3b032e8e1fd342261b153aeb375f9c0e8d882b34 (patch)
tree9e2228d0446836ddeefbb4f24f83589a155d7ed0
parent2edc85e953e003f8b8121e7757e9d45f5216f649 (diff)
First stab at ignoring compressed files from picker (#767)
-rw-r--r--helix-term/src/ui/mod.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index 810a9966..30a9ec6b 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -91,9 +91,25 @@ pub fn regex_prompt(
}
pub fn file_picker(root: PathBuf) -> FilePicker<PathBuf> {
- use ignore::Walk;
+ use ignore::{types::TypesBuilder, WalkBuilder};
use std::time;
- let files = Walk::new(&root).filter_map(|entry| {
+
+ // We want to exclude files that the editor can't handle yet
+ let mut type_builder = TypesBuilder::new();
+ let mut walk_builder = WalkBuilder::new(&root);
+ let walk_builder = match type_builder.add(
+ "compressed",
+ "*.{zip,gz,bz2,zst,lzo,sz,tgz,tbz2,lz,lz4,lzma,lzo,z,Z,xz,7z,rar,cab}",
+ ) {
+ Err(_) => &walk_builder,
+ _ => {
+ type_builder.negate("all");
+ let excluded_types = type_builder.build().unwrap();
+ walk_builder.types(excluded_types)
+ }
+ };
+
+ let files = walk_builder.build().filter_map(|entry| {
let entry = entry.ok()?;
// Path::is_dir() traverses symlinks, so we use it over DirEntry::is_dir
if entry.path().is_dir() {