Skip to content

Commit

Permalink
Merge pull request #97270 from timothyqiu/optional-edconfig
Browse files Browse the repository at this point in the history
Create `.editorconfig` file only on project creation
  • Loading branch information
Repiteo committed Oct 8, 2024
2 parents 3cc4e0a + 8086894 commit f31a2cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
16 changes: 0 additions & 16 deletions editor/editor_paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,22 +257,6 @@ EditorPaths::EditorPaths() {
}
}

// 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);

// Editor metadata dir.
Expand Down
15 changes: 15 additions & 0 deletions editor/project_manager/project_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,21 @@ void ProjectDialog::ok_pressed() {
fa_icon->store_string(get_default_project_icon());

EditorVCSInterface::create_vcs_metadata_files(EditorVCSInterface::VCSMetadata(vcs_metadata_selection->get_selected()), path);

// Ensures external editors and IDEs use UTF-8 encoding.
const String editor_config_path = path.path_join(".editorconfig");
Ref<FileAccess> f = FileAccess::open(editor_config_path, FileAccess::WRITE);
if (f.is_null()) {
// .editorconfig isn't so critical.
ERR_PRINT("Couldn't create .editorconfig in project path.");
} else {
f->store_line("root = true");
f->store_line("");
f->store_line("[*]");
f->store_line("charset = utf-8");
f->close();
FileAccess::set_hidden_attribute(editor_config_path, true);
}
}

// Two cases for importing a ZIP.
Expand Down
2 changes: 0 additions & 2 deletions modules/gdscript/tests/scripts/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# This file is required to workaround `.editorconfig` autogeneration (see #96845).

# Some tests handle invalid syntax deliberately; exclude relevant attributes.

[parser/features/mixed_indentation_on_blank_lines.gd]
Expand Down

0 comments on commit f31a2cc

Please sign in to comment.