Do not propose prettier formatters for documents in node_modules/

This commit is contained in:
Kirill Bulatov 2023-11-09 14:40:53 +02:00
parent ce40d5e0c5
commit 2e957bc564
2 changed files with 19 additions and 17 deletions

View file

@ -64,6 +64,12 @@ impl Prettier {
.components() .components()
.take_while(|component| component.as_os_str().to_string_lossy() != "node_modules") .take_while(|component| component.as_os_str().to_string_lossy() != "node_modules")
.collect::<PathBuf>(); .collect::<PathBuf>();
if path_to_check != locate_from {
log::debug!(
"Skipping prettier location for path {path_to_check:?} that is inside node_modules"
);
return Ok(ControlFlow::Break(()));
}
let path_to_check_metadata = fs let path_to_check_metadata = fs
.metadata(&path_to_check) .metadata(&path_to_check)
.await .await

View file

@ -173,8 +173,7 @@ pub struct Project {
struct DefaultPrettier { struct DefaultPrettier {
instance: Option<Shared<Task<Result<Arc<Prettier>, Arc<anyhow::Error>>>>>, instance: Option<Shared<Task<Result<Arc<Prettier>, Arc<anyhow::Error>>>>>,
installation_process: Option<Shared<Task<Result<(), Arc<anyhow::Error>>>>>, installation_process: Option<Shared<Task<Result<(), Arc<anyhow::Error>>>>>,
// TODO kb uncomment #[cfg(not(any(test, feature = "test-support")))]
// #[cfg(not(any(test, feature = "test-support")))]
installed_plugins: HashSet<&'static str>, installed_plugins: HashSet<&'static str>,
} }
@ -8540,18 +8539,17 @@ impl Project {
} }
} }
// TODO kb uncomment #[cfg(any(test, feature = "test-support"))]
// #[cfg(any(test, feature = "test-support"))] fn install_default_formatters(
// fn install_default_formatters( &mut self,
// &mut self, _worktree: Option<WorktreeId>,
// _worktree: Option<WorktreeId>, _new_language: &Language,
// _new_language: &Language, _language_settings: &LanguageSettings,
// _language_settings: &LanguageSettings, _cx: &mut ModelContext<Self>,
// _cx: &mut ModelContext<Self>, ) {
// ) { }
// }
// #[cfg(not(any(test, feature = "test-support")))] #[cfg(not(any(test, feature = "test-support")))]
fn install_default_formatters( fn install_default_formatters(
&mut self, &mut self,
worktree: Option<WorktreeId>, worktree: Option<WorktreeId>,
@ -8714,8 +8712,7 @@ fn start_default_prettier(
.get_or_insert_with(|| DefaultPrettier { .get_or_insert_with(|| DefaultPrettier {
instance: None, instance: None,
installation_process: None, installation_process: None,
// TODO kb uncomment #[cfg(not(any(test, feature = "test-support")))]
// #[cfg(not(any(test, feature = "test-support")))]
installed_plugins: HashSet::default(), installed_plugins: HashSet::default(),
}) })
.instance = Some(new_default_prettier.clone()); .instance = Some(new_default_prettier.clone());
@ -8797,8 +8794,7 @@ fn register_new_prettier(
} }
} }
// TODO kb uncomment #[cfg(not(any(test, feature = "test-support")))]
// #[cfg(not(any(test, feature = "test-support")))]
async fn install_default_prettier( async fn install_default_prettier(
plugins_to_install: HashSet<&'static str>, plugins_to_install: HashSet<&'static str>,
node: Arc<dyn NodeRuntime>, node: Arc<dyn NodeRuntime>,