From 36e0a72c77348d4a1f2195937dff8dba88f7e044 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 24 Aug 2017 00:06:56 -0300 Subject: -Code completion for enumerations -Disabled GDNative and GDNativeScript so build compiles again --- scene/gui/text_edit.cpp | 16 +++++++++++++--- scene/gui/text_edit.h | 3 ++- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'scene') diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 245e7e04be..2c50b4e854 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -4319,6 +4319,7 @@ void TextEdit::_cancel_completion() { return; completion_active = false; + completion_forced = false; update(); } @@ -4386,13 +4387,19 @@ void TextEdit::_update_completion_candidates() { } } - if (cursor.column > 0 && l[cursor.column - 1] == '(' && !pre_keyword && !completion_strings[0].begins_with("\"")) { + if (cursor.column > 0 && l[cursor.column - 1] == '(' && !pre_keyword && !completion_forced) { cancel = true; } update(); - if (cancel || (!pre_keyword && s == "" && (cofs == 0 || !completion_prefixes.has(String::chr(l[cofs - 1]))))) { + bool prev_is_prefix = false; + if (cofs > 0 && completion_prefixes.has(String::chr(l[cofs - 1]))) + prev_is_prefix = true; + if (cofs > 1 && l[cofs - 1] == ' ' && completion_prefixes.has(String::chr(l[cofs - 2]))) //check with one space before prefix, to allow indent + prev_is_prefix = true; + + if (cancel || (!pre_keyword && s == "" && (cofs == 0 || !prev_is_prefix))) { //none to complete, cancel _cancel_completion(); return; @@ -4481,6 +4488,8 @@ void TextEdit::query_code_comple() { if (ofs > 0 && (inquote || _is_completable(l[ofs - 1]) || completion_prefixes.has(String::chr(l[ofs - 1])))) emit_signal("request_completion"); + else if (ofs > 1 && l[ofs - 1] == ' ' && completion_prefixes.has(String::chr(l[ofs - 2]))) //make it work with a space too, it's good enough + emit_signal("request_completion"); } void TextEdit::set_code_hint(const String &p_hint) { @@ -4492,12 +4501,13 @@ void TextEdit::set_code_hint(const String &p_hint) { update(); } -void TextEdit::code_complete(const Vector &p_strings) { +void TextEdit::code_complete(const Vector &p_strings, bool p_forced) { VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 1); raised_from_completion = true; completion_strings = p_strings; completion_active = true; + completion_forced = p_forced; completion_current = ""; completion_index = 0; _update_completion_candidates(); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 6321cad2da..7ab26322e7 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -205,6 +205,7 @@ class TextEdit : public Control { Vector completion_strings; Vector completion_options; bool completion_active; + bool completion_forced; String completion_current; String completion_base; int completion_index; @@ -522,7 +523,7 @@ public: void set_tooltip_request_func(Object *p_obj, const StringName &p_function, const Variant &p_udata); void set_completion(bool p_enabled, const Vector &p_prefixes); - void code_complete(const Vector &p_strings); + void code_complete(const Vector &p_strings, bool p_forced = false); void set_code_hint(const String &p_hint); void query_code_comple(); -- cgit v1.2.3