Do not show (running) when opening picker (#8148)

* only stream from background thread if necessary

If the file transversal is longer shorter 30ms it will now be performed
on the main thread. Spawning a thread can take a while (or rather it
takes a while until that thread is scheduled) so the files can actually
take a while to show up. This prevents the `(running)` indicator from
briefly showing up when opening the file picker in a small directory.

* run partial cargo update
main
Pascal Kuthe 1 year ago committed by GitHub
parent 8778083b5a
commit 0cfd46c14f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

49
Cargo.lock generated

@ -17,17 +17,6 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "ahash"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
dependencies = [
"getrandom",
"once_cell",
"version_check",
]
[[package]] [[package]]
name = "ahash" name = "ahash"
version = "0.8.3" version = "0.8.3"
@ -107,7 +96,7 @@ dependencies = [
"cc", "cc",
"cfg-if", "cfg-if",
"libc", "libc",
"miniz_oxide 0.7.1", "miniz_oxide",
"object", "object",
"rustc-demangle", "rustc-demangle",
] ]
@ -495,12 +484,12 @@ dependencies = [
[[package]] [[package]]
name = "flate2" name = "flate2"
version = "1.0.25" version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"miniz_oxide 0.6.2", "miniz_oxide",
] ]
[[package]] [[package]]
@ -1237,9 +1226,6 @@ name = "hashbrown"
version = "0.12.3" version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
dependencies = [
"ahash 0.7.6",
]
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
@ -1247,7 +1233,7 @@ version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
dependencies = [ dependencies = [
"ahash 0.8.3", "ahash",
"allocator-api2", "allocator-api2",
] ]
@ -1255,7 +1241,7 @@ dependencies = [
name = "helix-core" name = "helix-core"
version = "0.6.0" version = "0.6.0"
dependencies = [ dependencies = [
"ahash 0.8.3", "ahash",
"arc-swap", "arc-swap",
"bitflags 2.4.0", "bitflags 2.4.0",
"chrono", "chrono",
@ -1546,7 +1532,7 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e98c1d0ad70fc91b8b9654b1f33db55e59579d3b3de2bffdced0fdb810570cb8" checksum = "e98c1d0ad70fc91b8b9654b1f33db55e59579d3b3de2bffdced0fdb810570cb8"
dependencies = [ dependencies = [
"ahash 0.8.3", "ahash",
"hashbrown 0.12.3", "hashbrown 0.12.3",
] ]
@ -1722,15 +1708,6 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniz_oxide"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa"
dependencies = [
"adler",
]
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"
version = "0.7.1" version = "0.7.1"
@ -1764,9 +1741,9 @@ dependencies = [
[[package]] [[package]]
name = "nucleo" name = "nucleo"
version = "0.2.0" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ccab936f2c8ad271bb31430944d98d358f74153566ea323265497f5639b11b6" checksum = "ae5331f4bcce475cf28cb29c95366c3091af4b0aa7703f1a6bc858f29718fdf3"
dependencies = [ dependencies = [
"nucleo-matcher", "nucleo-matcher",
"parking_lot", "parking_lot",
@ -2509,13 +2486,9 @@ checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
[[package]] [[package]]
name = "unicode-linebreak" name = "unicode-linebreak"
version = "0.1.4" version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5faade31a542b8b35855fff6e8def199853b2da8da256da52f52f1316ee3137" checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f"
dependencies = [
"hashbrown 0.12.3",
"regex",
]
[[package]] [[package]]
name = "unicode-normalization" name = "unicode-normalization"

@ -190,7 +190,7 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> Picker
.build() .build()
.expect("failed to build excluded_types"); .expect("failed to build excluded_types");
walk_builder.types(excluded_types); walk_builder.types(excluded_types);
let files = walk_builder.build().filter_map(|entry| { let mut files = walk_builder.build().filter_map(|entry| {
let entry = entry.ok()?; let entry = entry.ok()?;
if !entry.file_type()?.is_file() { if !entry.file_type()?.is_file() {
return None; return None;
@ -211,13 +211,27 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> Picker
}) })
.with_preview(|_editor, path| Some((path.clone().into(), None))); .with_preview(|_editor, path| Some((path.clone().into(), None)));
let injector = picker.injector(); let injector = picker.injector();
std::thread::spawn(move || { let timeout = std::time::Instant::now() + std::time::Duration::from_millis(30);
for file in files {
if injector.push(file).is_err() { let mut hit_timeout = false;
break; for file in &mut files {
} if injector.push(file).is_err() {
break;
} }
}); if std::time::Instant::now() >= timeout {
hit_timeout = true;
break;
}
}
if hit_timeout {
std::thread::spawn(move || {
for file in files {
if injector.push(file).is_err() {
break;
}
}
});
}
picker picker
} }

Loading…
Cancel
Save