diff options
author | Yuri Sizov <yuris@humnom.net> | 2023-07-12 17:15:51 +0200 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-07-12 17:15:51 +0200 |
commit | d13369eee12fc264ef9df0ae86d6a19165e58449 (patch) | |
tree | d541cc09e4d340d78ee39300a1321915dba52309 | |
parent | 223370cb6413285f5da7c1ac5f767c2a2914fe0c (diff) | |
parent | 68c24f99938ed850e34ec56abc44ab7f2aa0b47e (diff) | |
download | redot-engine-d13369eee12fc264ef9df0ae86d6a19165e58449.tar.gz |
Merge pull request #68140 from quinnyo/auto-complete-option
Add editor setting to toggle automatic code completion
-rw-r--r-- | doc/classes/EditorSettings.xml | 3 | ||||
-rw-r--r-- | editor/code_editor.cpp | 4 | ||||
-rw-r--r-- | editor/code_editor.h | 1 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 3 |
4 files changed, 9 insertions, 2 deletions
diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index ca27538c1f..05a3e22830 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -837,6 +837,9 @@ <member name="text_editor/completion/code_complete_delay" type="float" setter="" getter=""> The delay in seconds after which autocompletion suggestions should be displayed when the user stops typing. </member> + <member name="text_editor/completion/code_complete_enabled" type="bool" setter="" getter=""> + If [code]true[/code], code completion will be triggered automatically after [member text_editor/completion/code_complete_delay]. If [code]false[/code], you can still trigger completion manually by pressing [kbd]Ctrl + Space[/kbd] ([kbd]Cmd + Space[/kbd] on macOS). + </member> <member name="text_editor/completion/complete_file_paths" type="bool" setter="" getter=""> If [code]true[/code], provides autocompletion suggestions for file paths in methods such as [code]load()[/code] and [code]preload()[/code]. </member> diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 78b01b6c78..cde74e0854 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -905,7 +905,7 @@ void CodeTextEditor::_line_col_changed() { } void CodeTextEditor::_text_changed() { - if (text_editor->is_insert_text_operation()) { + if (code_complete_enabled && text_editor->is_insert_text_operation()) { code_complete_timer_line = text_editor->get_caret_line(); code_complete_timer->start(); } @@ -1737,6 +1737,7 @@ void CodeTextEditor::_apply_settings_change() { 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")); } @@ -2011,6 +2012,7 @@ CodeTextEditor::CodeTextEditor() { idle->set_one_shot(true); idle->set_wait_time(EDITOR_GET("text_editor/completion/idle_parse_delay")); + code_complete_enabled = EDITOR_GET("text_editor/completion/code_complete_enabled"); code_complete_timer = memnew(Timer); add_child(code_complete_timer); code_complete_timer->set_one_shot(true); diff --git a/editor/code_editor.h b/editor/code_editor.h index a83bb96771..c18154a1ef 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -157,6 +157,7 @@ class CodeTextEditor : public VBoxContainer { Label *info = nullptr; Timer *idle = nullptr; + 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 8634b94858..537e862a51 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -597,7 +597,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { // Completion EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "text_editor/completion/idle_parse_delay", 2.0, "0.1,10,0.01") _initial_set("text_editor/completion/auto_brace_complete", true); - EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "text_editor/completion/code_complete_delay", 0.3, "0.01,5,0.01") + _initial_set("text_editor/completion/code_complete_enabled", true); + EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "text_editor/completion/code_complete_delay", 0.3, "0.01,5,0.01,or_greater") _initial_set("text_editor/completion/put_callhint_tooltip_below_current_line", true); _initial_set("text_editor/completion/complete_file_paths", true); _initial_set("text_editor/completion/add_type_hints", false); |