summaryrefslogtreecommitdiff
path: root/helix-term/src/ui/mod.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-11-06 15:28:19 +0000
committerBlaž Hrastnik2021-11-06 15:28:19 +0000
commitf2b709a3c3a9cc036bfea46734efd7e4100eb34b (patch)
treead5f921f13659e5ba395442e13389af317ee81b0 /helix-term/src/ui/mod.rs
parentcde57dae356021c6ca8c2a2ed68777bd9d0bc0b2 (diff)
parentf979bdc442ab3150a369ff8bee0703e90e32e2a4 (diff)
Merge branch 'master' into debug
Diffstat (limited to 'helix-term/src/ui/mod.rs')
-rw-r--r--helix-term/src/ui/mod.rs23
1 files changed, 20 insertions, 3 deletions
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index e66673ca..00c70cea 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -29,6 +29,7 @@ pub fn regex_prompt(
cx: &mut crate::commands::Context,
prompt: std::borrow::Cow<'static, str>,
history_register: Option<char>,
+ completion_fn: impl FnMut(&str) -> Vec<prompt::Completion> + 'static,
fun: impl Fn(&mut View, &mut Document, Regex, PromptEvent) + 'static,
) -> Prompt {
let (view, doc) = current!(cx.editor);
@@ -38,7 +39,7 @@ pub fn regex_prompt(
Prompt::new(
prompt,
history_register,
- |_input: &str| Vec::new(), // this is fine because Vec::new() doesn't allocate
+ completion_fn,
move |cx: &mut crate::compositor::Context, input: &str, event: PromptEvent| {
match event {
PromptEvent::Abort => {
@@ -92,9 +93,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() {