diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/text_edit.cpp | 21 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 2 |
2 files changed, 18 insertions, 5 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index e106f0dfc6..78fd699dd0 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -4122,7 +4122,7 @@ void TextEdit::_update_completion_candidates() { } } - if (l[cursor.column - 1] == '(' && !pre_keyword && !completion_strings[0].begins_with("\"")) { + if (cursor.column > 0 && l[cursor.column - 1] == '(' && !pre_keyword && !completion_strings[0].begins_with("\"")) { cancel = true; } @@ -4140,13 +4140,26 @@ void TextEdit::_update_completion_candidates() { int ci_match=0; Vector<float> sim_cache; for(int i=0;i<completion_strings.size();i++) { + if (s == completion_strings[i]) { + // A perfect match, stop completion + _cancel_completion(); + return; + } if (s.is_subsequence_ofi(completion_strings[i])) { // don't remove duplicates if no input is provided if (s != "" && completion_options.find(completion_strings[i]) != -1) { continue; } // Calculate the similarity to keep completions in good order - float similarity = s.similarity(completion_strings[i]); + float similarity; + if (completion_strings[i].to_lower().begins_with(s.to_lower())) { + // Substrings are the best candidates + similarity = 1.1; + } else { + // Otherwise compute the similarity + similarity = s.to_lower().similarity(completion_strings[i].to_lower()); + } + int comp_size = completion_options.size(); if (comp_size == 0) { completion_options.push_back(completion_strings[i]); @@ -4156,8 +4169,8 @@ void TextEdit::_update_completion_candidates() { int pos = 0; do { comp_sim = sim_cache[pos++]; - } while(pos < comp_size && similarity <= comp_sim); - pos--; // Pos will be off by one + } while(pos < comp_size && similarity < comp_sim); + pos = similarity > comp_sim ? pos - 1 : pos; // Pos will be off by one completion_options.insert(pos, completion_strings[i]); sim_cache.insert(pos, similarity); } diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index db14c15db8..581103931e 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -2279,7 +2279,7 @@ void Tree::_input_event(InputEvent p_event) { update(); } - if (pressing_for_editor && popup_edited_item && popup_edited_item->get_cell_mode(popup_edited_item_col)==TreeItem::CELL_MODE_RANGE) { + if (pressing_for_editor && popup_edited_item && (popup_edited_item->get_cell_mode(popup_edited_item_col)==TreeItem::CELL_MODE_RANGE || popup_edited_item->get_cell_mode(popup_edited_item_col)==TreeItem::CELL_MODE_RANGE_EXPRESSION)) { //range drag if (!range_drag_enabled) { |