Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/ui/picker.rs')
| -rw-r--r-- | helix-term/src/ui/picker.rs | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 4f77f8b9..11d3c04c 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -610,15 +610,11 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> { let preview = std::fs::metadata(&path) .and_then(|metadata| { if metadata.is_dir() { - let files = super::directory_content(&path, editor)?; + let files = super::directory_content(&path)?; let file_names: Vec<_> = files .iter() - .filter_map(|(file_path, is_dir)| { - let name = file_path - .strip_prefix(&path) - .map(|p| Some(p.as_os_str())) - .unwrap_or_else(|_| file_path.file_name())? - .to_string_lossy(); + .filter_map(|(path, is_dir)| { + let name = path.file_name()?.to_string_lossy(); if *is_dir { Some((format!("{}/", name), true)) } else { @@ -900,7 +896,7 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> { if let Some((preview, range)) = self.get_preview(cx.editor) { let doc = match preview.document() { Some(doc) - if range.is_none_or(|(start, end)| { + if range.map_or(true, |(start, end)| { start <= end && end <= doc.text().len_lines() }) => { @@ -1048,23 +1044,23 @@ impl<I: 'static + Send + Sync, D: 'static + Send + Sync> Component for Picker<I, let close_fn = |picker: &mut Self| { // if the picker is very large don't store it as last_picker to avoid // excessive memory consumption - let callback: compositor::Callback = - if picker.matcher.snapshot().item_count() > 1_000_000 { - Box::new(|compositor: &mut Compositor, _ctx| { - // remove the layer - compositor.pop(); - }) - } else { - // stop streaming in new items in the background, really we should - // be restarting the stream somehow once the picker gets - // reopened instead (like for an FS crawl) that would also remove the - // need for the special case above but that is pretty tricky - picker.version.fetch_add(1, atomic::Ordering::Relaxed); - Box::new(|compositor: &mut Compositor, _ctx| { - // remove the layer - compositor.last_picker = compositor.pop(); - }) - }; + let callback: compositor::Callback = if picker.matcher.snapshot().item_count() > 100_000 + { + Box::new(|compositor: &mut Compositor, _ctx| { + // remove the layer + compositor.pop(); + }) + } else { + // stop streaming in new items in the background, really we should + // be restarting the stream somehow once the picker gets + // reopened instead (like for an FS crawl) that would also remove the + // need for the special case above but that is pretty tricky + picker.version.fetch_add(1, atomic::Ordering::Relaxed); + Box::new(|compositor: &mut Compositor, _ctx| { + // remove the layer + compositor.last_picker = compositor.pop(); + }) + }; EventResult::Consumed(Some(callback)) }; |