Fix a bug when extension loading is failed after it's folder is viewed by MacOS finder (#8111)

Fixes #8096

# Bug description

I was experimenting with adding extensions and almost went crazy trying
to make my demo extension work. It appeared that I was copying files
with Finder that creates hidden `.DS_Store` files which interfered with
Zed's loading logic. It assumes that `languages/` directory contains
only directories and never files and so it crashes when meets
`.DS_Store`. This makes any extension stop working after it has been
viewed via Finder

# Change

Check if path is directory when loading extension languages (so it will
skip .DS_Store files)
This commit is contained in:
Ivan Buryak 2024-02-21 21:46:58 +05:00 committed by GitHub
parent d3745a3931
commit 7bf16f263e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -651,6 +651,12 @@ impl ExtensionStore {
let Ok(relative_path) = language_path.strip_prefix(&extension_dir) else {
continue;
};
let Ok(Some(fs_metadata)) = fs.metadata(&language_path).await else {
continue;
};
if !fs_metadata.is_dir {
continue;
}
let config = fs.load(&language_path.join("config.toml")).await?;
let config = ::toml::from_str::<LanguageConfig>(&config)?;