Don't terminate search if begin_key doesn't fit

Previously this code would continue onto the next iteration of the loop if the line was smaller in size than begin_key, meaning that a situation where begin_key.length() > end_key.length() would cause weird behavior with newlines. Now both the checks for begin_key and end_key are in their own condition and do not skip the entire iteration if they can't be found.
This commit is contained in:
Zatherz 2019-10-24 21:59:02 +02:00
parent 40a25c1e86
commit 72d2248276

View File

@ -161,12 +161,13 @@ void TextEdit::Text::_update_line_cache(int p_line) const {
/* BEGIN */ /* BEGIN */
int lr = cr.begin_key.length(); int lr = cr.begin_key.length();
if (lr == 0 || lr > left) const CharType *kc;
continue; bool match;
const CharType *kc = cr.begin_key.c_str(); if (lr != 0 && lr <= left) {
kc = cr.begin_key.c_str();
bool match = true; match = true;
for (int k = 0; k < lr; k++) { for (int k = 0; k < lr; k++) {
if (kc[k] != str[i + k]) { if (kc[k] != str[i + k]) {
@ -185,13 +186,12 @@ void TextEdit::Text::_update_line_cache(int p_line) const {
break; break;
} }
}
/* END */ /* END */
lr = cr.end_key.length(); lr = cr.end_key.length();
if (lr == 0 || lr > left) if (lr != 0 && lr <= left) {
continue;
kc = cr.end_key.c_str(); kc = cr.end_key.c_str();
match = true; match = true;
@ -215,6 +215,7 @@ void TextEdit::Text::_update_line_cache(int p_line) const {
} }
} }
} }
}
} }
const Map<int, TextEdit::Text::ColorRegionInfo> &TextEdit::Text::get_color_region_info(int p_line) const { const Map<int, TextEdit::Text::ColorRegionInfo> &TextEdit::Text::get_color_region_info(int p_line) const {