mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 21:13:02 +00:00
Fix incomplete language names list being used for JSON schema
For now, since initializing the languages themselves is still async, create a parallel duplicated code path that is synchronous, and just provided the language names.
This commit is contained in:
parent
cd87c5552e
commit
4775d839d7
3 changed files with 25 additions and 4 deletions
|
@ -248,7 +248,7 @@ impl Settings {
|
|||
|
||||
pub fn settings_file_json_schema(
|
||||
theme_names: Vec<String>,
|
||||
language_names: Vec<String>,
|
||||
language_names: &[String],
|
||||
) -> serde_json::Value {
|
||||
let settings = SchemaSettings::draft07().with(|settings| {
|
||||
settings.option_add_null_type = false;
|
||||
|
@ -275,8 +275,13 @@ pub fn settings_file_json_schema(
|
|||
instance_type: Some(SingleOrVec::Single(Box::new(InstanceType::Object))),
|
||||
object: Some(Box::new(ObjectValidation {
|
||||
properties: language_names
|
||||
.into_iter()
|
||||
.map(|name| (name, Schema::new_ref("#/definitions/EditorSettings".into())))
|
||||
.iter()
|
||||
.map(|name| {
|
||||
(
|
||||
name.clone(),
|
||||
Schema::new_ref("#/definitions/EditorSettings".into()),
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
..Default::default()
|
||||
})),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use gpui::executor::Background;
|
||||
pub use language::*;
|
||||
use lazy_static::lazy_static;
|
||||
use rust_embed::RustEmbed;
|
||||
use std::{borrow::Cow, str, sync::Arc};
|
||||
|
||||
|
@ -17,6 +18,21 @@ mod typescript;
|
|||
#[exclude = "*.rs"]
|
||||
struct LanguageDir;
|
||||
|
||||
// TODO - Remove this once the `init` function is synchronous again.
|
||||
lazy_static! {
|
||||
pub static ref LANGUAGE_NAMES: Vec<String> = LanguageDir::iter()
|
||||
.filter_map(|path| {
|
||||
if path.ends_with("config.toml") {
|
||||
let config = LanguageDir::get(&path)?;
|
||||
let config = toml::from_slice::<LanguageConfig>(&config.data).ok()?;
|
||||
Some(config.name.to_string())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
|
||||
pub async fn init(languages: Arc<LanguageRegistry>, _executor: Arc<Background>) {
|
||||
for (name, grammar, lsp_adapter) in [
|
||||
(
|
||||
|
|
|
@ -209,7 +209,7 @@ pub fn initialize_workspace(
|
|||
cx.emit(workspace::Event::PaneAdded(workspace.active_pane().clone()));
|
||||
|
||||
let theme_names = app_state.themes.list().collect();
|
||||
let language_names = app_state.languages.language_names();
|
||||
let language_names = &languages::LANGUAGE_NAMES;
|
||||
|
||||
workspace.project().update(cx, |project, cx| {
|
||||
let action_names = cx.all_action_names().collect::<Vec<_>>();
|
||||
|
|
Loading…
Reference in a new issue