You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-22 15:06:45 +00:00
CodeEdit: Use flag to recalculate characteristics
This commit is contained in:
@@ -617,13 +617,13 @@ TypedArray<int> ScriptLanguage::CodeCompletionOption::get_option_characteristics
|
||||
// Return characteristics of the match found by order of importance.
|
||||
// Matches will be ranked by a lexicographical order on the vector returned by this function.
|
||||
// The lower values indicate better matches and that they should go before in the order of appearance.
|
||||
if (last_matches == matches) {
|
||||
if (!matches_dirty) {
|
||||
return charac;
|
||||
}
|
||||
charac.clear();
|
||||
// Ensure base is not empty and at the same time that matches is not empty too.
|
||||
if (p_base.length() == 0) {
|
||||
last_matches = matches;
|
||||
matches_dirty = false;
|
||||
charac.push_back(location);
|
||||
return charac;
|
||||
}
|
||||
@@ -642,7 +642,7 @@ TypedArray<int> ScriptLanguage::CodeCompletionOption::get_option_characteristics
|
||||
charac.push_back(bad_case);
|
||||
charac.push_back(location);
|
||||
charac.push_back(matches[0].first);
|
||||
last_matches = matches;
|
||||
matches_dirty = false;
|
||||
return charac;
|
||||
}
|
||||
|
||||
@@ -652,7 +652,7 @@ void ScriptLanguage::CodeCompletionOption::clear_characteristics() {
|
||||
|
||||
TypedArray<int> ScriptLanguage::CodeCompletionOption::get_option_cached_characteristics() const {
|
||||
// Only returns the cached value and warns if it was not updated since the last change of matches.
|
||||
if (last_matches != matches) {
|
||||
if (matches_dirty) {
|
||||
WARN_PRINT("Characteristics are not up to date.");
|
||||
}
|
||||
|
||||
|
||||
@@ -315,7 +315,7 @@ public:
|
||||
Ref<Resource> icon;
|
||||
Variant default_value;
|
||||
Vector<Pair<int, int>> matches;
|
||||
Vector<Pair<int, int>> last_matches = { { -1, -1 } }; // This value correspond to an impossible match
|
||||
bool matches_dirty = true; // Must be set when mutating `matches`, so that sorting characteristics are recalculated.
|
||||
int location = LOCATION_OTHER;
|
||||
String theme_color_name;
|
||||
|
||||
|
||||
@@ -427,6 +427,7 @@ public:
|
||||
option.matches.push_back(Pair<int, int>(matches[j], matches[j + 1]));
|
||||
}
|
||||
}
|
||||
option.matches_dirty = true;
|
||||
r_options->push_back(option);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3637,6 +3637,7 @@ void CodeEdit::_filter_code_completion_candidates_impl() {
|
||||
|
||||
for (ScriptLanguage::CodeCompletionOption &option : code_completion_option_sources) {
|
||||
option.matches.clear();
|
||||
option.matches_dirty = true;
|
||||
if (single_quote && option.display.is_quoted()) {
|
||||
option.display = option.display.unquote().quote("'");
|
||||
}
|
||||
@@ -3722,6 +3723,7 @@ void CodeEdit::_filter_code_completion_candidates_impl() {
|
||||
// go through all possible matches to get the best one as defined by CodeCompletionOptionCompare
|
||||
if (all_possible_subsequence_matches.size() > 0) {
|
||||
option.matches = all_possible_subsequence_matches[0];
|
||||
option.matches_dirty = true;
|
||||
option.get_option_characteristics(string_to_complete);
|
||||
all_possible_subsequence_matches = all_possible_subsequence_matches.slice(1);
|
||||
if (all_possible_subsequence_matches.size() > 0) {
|
||||
@@ -3730,6 +3732,7 @@ void CodeEdit::_filter_code_completion_candidates_impl() {
|
||||
compared_option.clear_characteristics();
|
||||
for (Vector<Pair<int, int>> &matches : all_possible_subsequence_matches) {
|
||||
compared_option.matches = matches;
|
||||
compared_option.matches_dirty = true;
|
||||
compared_option.get_option_characteristics(string_to_complete);
|
||||
if (compare(compared_option, option)) {
|
||||
option = compared_option;
|
||||
|
||||
Reference in New Issue
Block a user