Copy setting and keymap files from legacy config locations

This commit is contained in:
Antonio Scandurra 2022-07-29 09:57:38 +02:00
parent 5f6e4c7d91
commit f2d92d640d
3 changed files with 45 additions and 19 deletions

View file

@ -223,11 +223,11 @@ pub fn initialize_workspace(
},
"schemas": [
{
"fileMatch": [".zed/settings.json"],
"fileMatch": [schema_file_match(&*paths::SETTINGS)],
"schema": settings_file_json_schema(theme_names, language_names),
},
{
"fileMatch": [".zed/keymap.json"],
"fileMatch": [schema_file_match(&*paths::KEYMAP)],
"schema": keymap_file_json_schema(&action_names),
}
]
@ -385,7 +385,6 @@ fn open_config_file(
cx.spawn(|workspace, mut cx| async move {
let fs = &app_state.fs;
if !fs.is_file(path).await {
fs.create_dir(&paths::CONFIG_DIR).await?;
fs.create_file(path, Default::default()).await?;
fs.save(path, &default_content(), Default::default())
.await?;
@ -481,6 +480,11 @@ fn open_bundled_config_file(
});
}
fn schema_file_match(path: &Path) -> &Path {
path.strip_prefix(path.parent().unwrap().parent().unwrap())
.unwrap()
}
#[cfg(test)]
mod tests {
use super::*;