diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml
index a8662e00698..26283566491 100644
--- a/doc/classes/EditorSettings.xml
+++ b/doc/classes/EditorSettings.xml
@@ -1292,6 +1292,9 @@
The delay in seconds after which the script editor should check for errors when the user stops typing.
+
+ The delay used instead of [member text_editor/completion/idle_parse_delay], when the parser has found errors. A lower value should feel more responsive while fixing code, but may cause notable stuttering and increase CPU usage.
+
If [code]true[/code], the code completion tooltip will appear below the current line unless there is no space on screen below the current line. If [code]false[/code], the code completion tooltip will appear above the current line.
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 05eeef4fc93..e193cc2a7e1 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -1119,7 +1119,12 @@ void CodeTextEditor::update_editor_settings() {
text_editor->set_code_hint_draw_below(EDITOR_GET("text_editor/completion/put_callhint_tooltip_below_current_line"));
code_complete_enabled = EDITOR_GET("text_editor/completion/code_complete_enabled");
code_complete_timer->set_wait_time(EDITOR_GET("text_editor/completion/code_complete_delay"));
- idle->set_wait_time(EDITOR_GET("text_editor/completion/idle_parse_delay"));
+ bool first_time = idle_time == 0.0;
+ idle_time = EDITOR_GET("text_editor/completion/idle_parse_delay");
+ idle_time_with_errors = EDITOR_GET("text_editor/completion/idle_parse_delay_with_errors_found");
+ if (first_time) {
+ idle->set_wait_time(idle_time);
+ }
// Appearance: Guidelines
if (EDITOR_GET("text_editor/appearance/guidelines/show_line_length_guidelines")) {
@@ -1624,8 +1629,11 @@ void CodeTextEditor::_notification(int p_what) {
void CodeTextEditor::set_error_count(int p_error_count) {
error_button->set_text(itos(p_error_count));
error_button->set_visible(p_error_count > 0);
- if (!p_error_count) {
+ if (p_error_count > 0) {
_set_show_errors_panel(false);
+ idle->set_wait_time(idle_time_with_errors); // Parsing should happen sooner.
+ } else {
+ idle->set_wait_time(idle_time);
}
}
@@ -1797,7 +1805,6 @@ CodeTextEditor::CodeTextEditor() {
add_child(status_bar);
status_bar->set_h_size_flags(SIZE_EXPAND_FILL);
status_bar->set_custom_minimum_size(Size2(0, 24 * EDSCALE)); // Adjust for the height of the warning icon.
-
idle = memnew(Timer);
add_child(idle);
idle->set_one_shot(true);
diff --git a/editor/code_editor.h b/editor/code_editor.h
index c1c65a2a4a5..d4129810dec 100644
--- a/editor/code_editor.h
+++ b/editor/code_editor.h
@@ -174,6 +174,8 @@ class CodeTextEditor : public VBoxContainer {
Label *info = nullptr;
Timer *idle = nullptr;
+ float idle_time = 0.0f;
+ float idle_time_with_errors = 0.0f;
bool code_complete_enabled = true;
Timer *code_complete_timer = nullptr;
int code_complete_timer_line = 0;
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index b0d1c3e6bb1..22f551517f4 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -724,6 +724,7 @@ void EditorSettings::_load_defaults(Ref p_extra_config) {
// Completion
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "text_editor/completion/idle_parse_delay", 1.5, "0.1,10,0.01")
+ EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "text_editor/completion/idle_parse_delay_with_errors_found", 0.5, "0.1,5,0.01")
_initial_set("text_editor/completion/auto_brace_complete", true, true);
_initial_set("text_editor/completion/code_complete_enabled", true, true);
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "text_editor/completion/code_complete_delay", 0.3, "0.01,5,0.01,or_greater")