Add support for detecting tests in source files, and implement it for Rust (#11195)
Continuing work from #10873 Release Notes: - N/A --------- Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
co-authored by
Mikayla
parent
14c7782ce6
commit
5a71d8c7f1
+32
-1
@@ -297,7 +297,7 @@ fn init_ui(args: Args) {
|
||||
|
||||
load_user_themes_in_background(fs.clone(), cx);
|
||||
watch_themes(fs.clone(), cx);
|
||||
|
||||
watch_languages(fs.clone(), languages.clone(), cx);
|
||||
watch_file_types(fs.clone(), cx);
|
||||
|
||||
languages.set_theme(cx.theme().clone());
|
||||
@@ -861,6 +861,37 @@ fn watch_themes(fs: Arc<dyn fs::Fs>, cx: &mut AppContext) {
|
||||
.detach()
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
fn watch_languages(fs: Arc<dyn fs::Fs>, languages: Arc<LanguageRegistry>, cx: &mut AppContext) {
|
||||
use std::time::Duration;
|
||||
|
||||
let path = {
|
||||
let p = Path::new("crates/languages/src");
|
||||
let Ok(full_path) = p.canonicalize() else {
|
||||
return;
|
||||
};
|
||||
full_path
|
||||
};
|
||||
|
||||
cx.spawn(|_| async move {
|
||||
let mut events = fs.watch(path.as_path(), Duration::from_millis(100)).await;
|
||||
while let Some(event) = events.next().await {
|
||||
let has_language_file = event.iter().any(|path| {
|
||||
path.extension()
|
||||
.map(|ext| ext.to_string_lossy().as_ref() == "scm")
|
||||
.unwrap_or(false)
|
||||
});
|
||||
if has_language_file {
|
||||
languages.reload();
|
||||
}
|
||||
}
|
||||
})
|
||||
.detach()
|
||||
}
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
fn watch_languages(_fs: Arc<dyn fs::Fs>, _languages: Arc<LanguageRegistry>, _cx: &mut AppContext) {}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
fn watch_file_types(fs: Arc<dyn fs::Fs>, cx: &mut AppContext) {
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -168,19 +168,14 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||
project.update(cx, |project, cx| {
|
||||
let fs = app_state.fs.clone();
|
||||
project.task_inventory().update(cx, |inventory, cx| {
|
||||
let tasks_file_rx =
|
||||
watch_config_file(&cx.background_executor(), fs, paths::TASKS.clone());
|
||||
inventory.add_source(
|
||||
TaskSourceKind::AbsPath {
|
||||
id_base: "global_tasks",
|
||||
abs_path: paths::TASKS.clone(),
|
||||
},
|
||||
|cx| {
|
||||
let tasks_file_rx = watch_config_file(
|
||||
&cx.background_executor(),
|
||||
fs,
|
||||
paths::TASKS.clone(),
|
||||
);
|
||||
StaticSource::new(TrackedFile::new(tasks_file_rx, cx), cx)
|
||||
},
|
||||
StaticSource::new(TrackedFile::new(tasks_file_rx, cx)),
|
||||
cx,
|
||||
);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user