Skip to content

Commit 8086894

Browse files
committed
Create .editorconfig file only on project creation
1 parent db66bd3 commit 8086894

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

editor/editor_paths.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -257,22 +257,6 @@ EditorPaths::EditorPaths() {
257257
}
258258
}
259259

260-
// Check that `.editorconfig` file exists.
261-
String project_editorconfig_path = "res://.editorconfig";
262-
if (!FileAccess::exists(project_editorconfig_path)) {
263-
Ref<FileAccess> f = FileAccess::open(project_editorconfig_path, FileAccess::WRITE);
264-
if (f.is_valid()) {
265-
f->store_line("root = true");
266-
f->store_line("");
267-
f->store_line("[*]");
268-
f->store_line("charset = utf-8");
269-
f->close();
270-
} else {
271-
ERR_PRINT("Failed to create file " + project_editorconfig_path.quote() + ".");
272-
}
273-
FileAccess::set_hidden_attribute(project_editorconfig_path, true);
274-
}
275-
276260
Engine::get_singleton()->set_shader_cache_path(project_data_dir);
277261

278262
// Editor metadata dir.

editor/project_manager/project_dialog.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,21 @@ void ProjectDialog::ok_pressed() {
552552
fa_icon->store_string(get_default_project_icon());
553553

554554
EditorVCSInterface::create_vcs_metadata_files(EditorVCSInterface::VCSMetadata(vcs_metadata_selection->get_selected()), path);
555+
556+
// Ensures external editors and IDEs use UTF-8 encoding.
557+
const String editor_config_path = path.path_join(".editorconfig");
558+
Ref<FileAccess> f = FileAccess::open(editor_config_path, FileAccess::WRITE);
559+
if (f.is_null()) {
560+
// .editorconfig isn't so critical.
561+
ERR_PRINT("Couldn't create .editorconfig in project path.");
562+
} else {
563+
f->store_line("root = true");
564+
f->store_line("");
565+
f->store_line("[*]");
566+
f->store_line("charset = utf-8");
567+
f->close();
568+
FileAccess::set_hidden_attribute(editor_config_path, true);
569+
}
555570
}
556571

557572
// Two cases for importing a ZIP.

modules/gdscript/tests/scripts/.editorconfig

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# This file is required to workaround `.editorconfig` autogeneration (see #96845).
2-
31
# Some tests handle invalid syntax deliberately; exclude relevant attributes.
42

53
[parser/features/mixed_indentation_on_blank_lines.gd]

0 commit comments

Comments
 (0)