Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

fuzzy: Remove `util` dependency (#61933)

Lukas Wirtha6a23c7b80a5
diff --git a/Cargo.lock b/Cargo.lock
index 33d5a4920ba..c06a7bc2cd6 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -7156,8 +7156,9 @@ name = "fuzzy"
version = "0.1.0"
dependencies = [
"gpui",
+ "gpui_util",
"log",
- "util",
+ "path",
]
[[package]]
diff --git a/crates/fuzzy/Cargo.toml b/crates/fuzzy/Cargo.toml
index 7df2142fa18..7bbad6786df 100644
--- a/crates/fuzzy/Cargo.toml
+++ b/crates/fuzzy/Cargo.toml
@@ -14,8 +14,6 @@ doctest = false
[dependencies]
gpui.workspace = true
-util.workspace = true
+gpui_util.workspace = true
+path.workspace = true
log.workspace = true
-
-[dev-dependencies]
-util = {workspace = true, features = ["test-support"]}
diff --git a/crates/fuzzy/src/matcher.rs b/crates/fuzzy/src/matcher.rs
index f22c9d3db39..44f467f15be 100644
--- a/crates/fuzzy/src/matcher.rs
+++ b/crates/fuzzy/src/matcher.rs
@@ -322,7 +322,7 @@ impl<'a> Matcher<'a> {
#[cfg(test)]
mod tests {
- use util::rel_path::{RelPath, rel_path};
+ use path::rel_path::{RelPath, rel_path};
use crate::{PathMatch, PathMatchCandidate};
diff --git a/crates/fuzzy/src/paths.rs b/crates/fuzzy/src/paths.rs
index 6420799403b..e16639f9e13 100644
--- a/crates/fuzzy/src/paths.rs
+++ b/crates/fuzzy/src/paths.rs
@@ -1,4 +1,5 @@
use gpui::BackgroundExecutor;
+use path::{PathStyle, rel_path::RelPath};
use std::{
cmp::{self, Ordering},
sync::{
@@ -6,7 +7,6 @@ use std::{
atomic::{self, AtomicBool},
},
};
-use util::{paths::PathStyle, rel_path::RelPath};
use crate::{
CharBag,
@@ -135,7 +135,7 @@ pub fn match_fixed_path_set(
distance_to_relative_ancestor: usize::MAX,
},
);
- util::truncate_to_bottom_n_sorted_by(&mut results, max_results, &|a, b| b.cmp(a));
+ gpui_util::truncate_to_bottom_n_sorted_by(&mut results, max_results, &|a, b| b.cmp(a));
results
}
@@ -256,7 +256,7 @@ pub async fn match_path_sets<'a, Set: PathMatchCandidateSet<'a>>(
}
let mut results = segment_results.concat();
- util::truncate_to_bottom_n_sorted_by(&mut results, max_results, &|a, b| b.cmp(a));
+ gpui_util::truncate_to_bottom_n_sorted_by(&mut results, max_results, &|a, b| b.cmp(a));
results
}
@@ -277,7 +277,7 @@ fn distance_between_paths(path: &RelPath, relative_to: &RelPath) -> usize {
#[cfg(test)]
mod tests {
- use util::rel_path::RelPath;
+ use path::rel_path::RelPath;
use super::distance_between_paths;
diff --git a/crates/fuzzy/src/strings.rs b/crates/fuzzy/src/strings.rs
index fb191bd9dca..e8921950c54 100644
--- a/crates/fuzzy/src/strings.rs
+++ b/crates/fuzzy/src/strings.rs
@@ -195,6 +195,6 @@ where
}
let mut results = segment_results.concat();
- util::truncate_to_bottom_n_sorted_by(&mut results, max_results, &|a, b| b.cmp(a));
+ gpui_util::truncate_to_bottom_n_sorted_by(&mut results, max_results, &|a, b| b.cmp(a));
results
}
diff --git a/crates/util/src/paths.rs b/crates/util/src/paths.rs
index 321180a1f09..dd3321db79f 100644
--- a/crates/util/src/paths.rs
+++ b/crates/util/src/paths.rs
@@ -20,6 +20,7 @@ use path::rel_path::RelPathBuf;
pub use path::PathStyle;
/// Returns the path to the user's home directory.
+#[cfg(not(target_family = "wasm"))]
pub fn home_dir() -> &'static PathBuf {
static HOME_DIR: std::sync::OnceLock<PathBuf> = std::sync::OnceLock::new();
HOME_DIR.get_or_init(|| {
diff --git a/crates/util/src/util.rs b/crates/util/src/util.rs
index f21ed6e046b..6b8e85f2131 100644
--- a/crates/util/src/util.rs
+++ b/crates/util/src/util.rs
@@ -1,17 +1,25 @@
+#[cfg(not(target_family = "wasm"))]
pub mod archive;
+#[cfg(not(target_family = "wasm"))]
pub mod command;
-pub mod disambiguate;
+#[cfg(not(target_family = "wasm"))]
pub mod fs;
+#[cfg(not(target_family = "wasm"))]
+pub mod process;
+#[cfg(not(target_family = "wasm"))]
+pub mod shell;
+#[cfg(not(target_family = "wasm"))]
+pub mod shell_builder;
+#[cfg(not(target_family = "wasm"))]
+pub mod shell_env;
+
+pub mod disambiguate;
pub mod markdown;
pub mod path_list;
pub mod paths;
-pub mod process;
pub mod redact;
pub mod schemars;
pub mod serde;
-pub mod shell;
-pub mod shell_builder;
-pub mod shell_env;
pub mod size;
#[cfg(any(test, feature = "test-support"))]
pub mod test;
@@ -38,6 +46,7 @@ pub use take_until::*;
#[cfg(any(test, feature = "test-support"))]
pub use util_macros::{line_endings, path, uri};
+#[cfg(not(target_family = "wasm"))]
pub use self::shell::{
get_default_system_shell, get_default_system_shell_preferring_bash, get_system_shell,
};
@@ -288,6 +297,7 @@ fn load_shell_from_passwd() -> Result<()> {
}
/// Returns a shell escaped path for the current zed executable
+#[cfg(not(target_family = "wasm"))]
pub fn get_shell_safe_zed_path(shell_kind: shell::ShellKind) -> anyhow::Result<String> {
use anyhow::Context as _;
use paths::PathExt;