Change locate prettier method signature

This commit is contained in:
Kirill Bulatov 2023-11-09 14:23:33 +02:00
parent ad3b0bd227
commit 8be07eddcc
2 changed files with 64 additions and 52 deletions

View file

@ -69,7 +69,7 @@ use std::{
hash::Hash,
mem,
num::NonZeroU32,
ops::Range,
ops::{ControlFlow, Range},
path::{self, Component, Path, PathBuf},
process::Stdio,
str,
@ -173,7 +173,8 @@ pub struct Project {
struct DefaultPrettier {
instance: Option<Shared<Task<Result<Arc<Prettier>, Arc<anyhow::Error>>>>>,
installation_process: Option<Shared<Task<Result<(), Arc<anyhow::Error>>>>>,
#[cfg(not(any(test, feature = "test-support")))]
// TODO kb uncomment
// #[cfg(not(any(test, feature = "test-support")))]
installed_plugins: HashSet<&'static str>,
}
@ -8442,7 +8443,10 @@ impl Project {
})
.await
{
Ok(None) => {
Ok(ControlFlow::Break(())) => {
return None;
}
Ok(ControlFlow::Continue(None)) => {
let started_default_prettier =
project.update(&mut cx, |project, _| {
project
@ -8466,7 +8470,7 @@ impl Project {
}
}
}
Ok(Some(prettier_dir)) => {
Ok(ControlFlow::Continue(Some(prettier_dir))) => {
project.update(&mut cx, |project, _| {
project
.prettiers_per_worktree
@ -8536,17 +8540,18 @@ impl Project {
}
}
#[cfg(any(test, feature = "test-support"))]
fn install_default_formatters(
&mut self,
_worktree: Option<WorktreeId>,
_new_language: &Language,
_language_settings: &LanguageSettings,
_cx: &mut ModelContext<Self>,
) {
}
// TODO kb uncomment
// #[cfg(any(test, feature = "test-support"))]
// fn install_default_formatters(
// &mut self,
// _worktree: Option<WorktreeId>,
// _new_language: &Language,
// _language_settings: &LanguageSettings,
// _cx: &mut ModelContext<Self>,
// ) {
// }
#[cfg(not(any(test, feature = "test-support")))]
// #[cfg(not(any(test, feature = "test-support")))]
fn install_default_formatters(
&mut self,
worktree: Option<WorktreeId>,
@ -8593,7 +8598,7 @@ impl Project {
.await
})
}
None => Task::ready(Ok(None)),
None => Task::ready(Ok(ControlFlow::Break(()))),
};
let mut plugins_to_install = prettier_plugins;
let previous_installation_process =
@ -8622,8 +8627,9 @@ impl Project {
.context("locate prettier installation")
.map_err(Arc::new)?
{
Some(_non_default_prettier) => return Ok(()),
None => {
ControlFlow::Break(()) => return Ok(()),
ControlFlow::Continue(Some(_non_default_prettier)) => return Ok(()),
ControlFlow::Continue(None) => {
let mut needs_install = match previous_installation_process {
Some(previous_installation_process) => {
previous_installation_process.await.is_err()
@ -8708,7 +8714,8 @@ fn start_default_prettier(
.get_or_insert_with(|| DefaultPrettier {
instance: None,
installation_process: None,
#[cfg(not(any(test, feature = "test-support")))]
// TODO kb uncomment
// #[cfg(not(any(test, feature = "test-support")))]
installed_plugins: HashSet::default(),
})
.instance = Some(new_default_prettier.clone());
@ -8790,7 +8797,8 @@ fn register_new_prettier(
}
}
#[cfg(not(any(test, feature = "test-support")))]
// TODO kb uncomment
// #[cfg(not(any(test, feature = "test-support")))]
async fn install_default_prettier(
plugins_to_install: HashSet<&'static str>,
node: Arc<dyn NodeRuntime>,