A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.
Rust archive-managerdesktop-appdual-paneexplorer-alternativefile-browserfile-explorerfile-managerfluent-designgpu-acceleratedgpuimacosmicaproductivityquick-lookrustrust-guitabswindowswindows-11windows-explorer
Downloads: a finished row's tooltip shows the site and a short path, not the whole link
gelenmedyaf4998416f198
diff --git a/crates/rf-app/src/downloads_view.rs b/crates/rf-app/src/downloads_view.rsindex d0ba1855..47d2a126 100644--- a/crates/rf-app/src/downloads_view.rs+++ b/crates/rf-app/src/downloads_view.rs@@ -523,6 +523,26 @@ fn live_row(d: &Live, p: &Palette, me: WeakEntity<DownloadsView>) -> AnyElement.into_any_element()}+/// The tooltip of a finished download's row: where it came from, as the site and a short path. The whole address was shown before,+/// and a signed link (a cloud drive's, a CDN's) is hundreds of characters of numbers and tokens (hyperdownload issue 8).+fn source_tip(source: &str) -> String {+ const MAX: usize = 60;+ let rest = source.split_once("://").map_or(source, |(_, r)| r);+ let rest = rest.split(['?', '#']).next().unwrap_or(rest);+ let (host, path) = rest.split_once('/').map_or((rest, ""), |(h, p)| (h, p));+ let host = host.rsplit('@').next().unwrap_or(host);+ if path.is_empty() {+ return host.to_string();+ }+ let tip = format!("{host}/{path}");+ if tip.chars().count() <= MAX {+ return tip;+ }+ // the site, then the end of the path (the file's own name is there)+ let tail: String = path.chars().rev().take(MAX.saturating_sub(host.chars().count() + 3)).collect::<Vec<_>>().into_iter().rev().collect();+ format!("{host}/…{tail}")+}+fn done_row(i: usize, e: &Entry, there: bool, p: &Palette) -> AnyElement {let (open, show, forget) = (e.path.clone(), e.path.clone(), e.path.clone());let when = format::datetime(e.finished_ms);@@ -535,7 +555,7 @@ fn done_row(i: usize, e: &Entry, there: bool, p: &Palette) -> AnyElement {.rounded(theme::RADIUS_SM).hover(|s| s.bg(p.hover)).when(!e.source.is_empty(), |d| {- let src: SharedString = e.source.clone().into();+ let src: SharedString = source_tip(&e.source).into();d.tooltip(move |w, cx| gpui_kit::component::tooltip::Tooltip::new(src.clone()).build(w, cx))}).when(there, |d| d.cursor_pointer().on_click(move |ev, _, cx| {@@ -643,3 +663,18 @@ mod tests {assert_eq!(t.eta, Some(40));}}++#[cfg(test)]+mod source_tip_tests {+ use super::source_tip;++ #[test]+ fn a_long_signed_link_shows_its_site_and_the_end_of_its_path() {+ assert_eq!(source_tip("https://example.com/a/file.zip?sig=123456789"), "example.com/a/file.zip");+ assert_eq!(source_tip("https://user:[email protected]"), "host.net");+ let long = format!("https://drive.example.com/{}/movie.mkv?token={}", "1234567890".repeat(10), "9".repeat(200));+ let tip = source_tip(&long);+ assert!(tip.starts_with("drive.example.com/…") && tip.ends_with("movie.mkv"), "{tip}");+ assert!(tip.chars().count() <= 62, "{tip}");+ }+}