Merge pull request #96845 from bruvzg/edconfig

[Editor] Add .editorconfig to the projects.
This commit is contained in:
Rémi Verschelde 2024-09-11 12:35:27 +02:00
commit 4788f54d97
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 18 additions and 2 deletions

View File

@ -245,7 +245,7 @@ EditorPaths::EditorPaths() {
} }
} }
// Check that the project data directory '.gdignore' file exists // Check that the project data directory `.gdignore` file exists.
String project_data_gdignore_file_path = project_data_dir.path_join(".gdignore"); String project_data_gdignore_file_path = project_data_dir.path_join(".gdignore");
if (!FileAccess::exists(project_data_gdignore_file_path)) { if (!FileAccess::exists(project_data_gdignore_file_path)) {
// Add an empty .gdignore file to avoid scan. // Add an empty .gdignore file to avoid scan.
@ -253,10 +253,26 @@ EditorPaths::EditorPaths() {
if (f.is_valid()) { if (f.is_valid()) {
f->store_line(""); f->store_line("");
} else { } else {
ERR_PRINT("Failed to create file " + project_data_gdignore_file_path); ERR_PRINT("Failed to create file " + project_data_gdignore_file_path.quote() + ".");
} }
} }
// Check that `.editorconfig` file exists.
String project_editorconfig_path = "res://.editorconfig";
if (!FileAccess::exists(project_editorconfig_path)) {
Ref<FileAccess> f = FileAccess::open(project_editorconfig_path, FileAccess::WRITE);
if (f.is_valid()) {
f->store_line("root = true");
f->store_line("");
f->store_line("[*]");
f->store_line("charset = utf-8");
f->close();
} else {
ERR_PRINT("Failed to create file " + project_editorconfig_path.quote() + ".");
}
FileAccess::set_hidden_attribute(project_editorconfig_path, true);
}
Engine::get_singleton()->set_shader_cache_path(project_data_dir); Engine::get_singleton()->set_shader_cache_path(project_data_dir);
// Editor metadata dir. // Editor metadata dir.