diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-08-21 17:20:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-21 17:20:11 +0200 |
commit | 14c2f2fe28e6c639f4e3b15471c0f3f3e42890de (patch) | |
tree | f1faa9bba5afe608d1827bb3bd6988f67faa5c9e | |
parent | 2ffc1c4105dd2788d0f35917b9db3d6066837bf9 (diff) | |
parent | 545b46ac2f13fe4df316e370ac8e3bbb04c62070 (diff) |
Merge pull request #31450 from GodotExplorer/fix-31425
Fix filter quotes wraped insert completion options
-rw-r--r-- | scene/gui/text_edit.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index a771794f25..f137b2618b 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -6112,10 +6112,30 @@ void TextEdit::query_code_comple() { c--; } - 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"); + bool ignored = completion_active && !completion_options.empty(); + if (ignored) { + ScriptCodeCompletionOption::Kind kind = ScriptCodeCompletionOption::KIND_PLAIN_TEXT; + const ScriptCodeCompletionOption *previous_option = NULL; + for (int i = 0; i < completion_options.size(); i++) { + const ScriptCodeCompletionOption ¤t_option = completion_options[i]; + if (!previous_option) { + previous_option = ¤t_option; + kind = current_option.kind; + } + if (previous_option->kind != current_option.kind) { + ignored = false; + break; + } + } + ignored = ignored && (kind == ScriptCodeCompletionOption::KIND_FILE_PATH || kind == ScriptCodeCompletionOption::KIND_NODE_PATH || kind == ScriptCodeCompletionOption::KIND_SIGNAL); + } + + if (!ignored) { + 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) { |