Fixed crash in cursor movement

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@925 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-06-01 00:02:02 +00:00
parent ff9dc0ddf0
commit 3287ace29d
+3 -1
View File
@@ -943,7 +943,9 @@ void TextValueEditor::replaceSelection(const String& replacement, const String&
} else {
// try to find the best match to what text we expected to be around the cursor
size_t best_match = 0;
for (size_t i = min(start, expected_cursor) ; i <= max(real_value.size() - end_min, expected_cursor) ; ++i) {
size_t begin = min(start, expected_cursor);
size_t end = min(real_value.size(), max(real_value.size() - end_min, expected_cursor) + 1);
for (size_t i = begin ; i < end ; ++i) {
size_t match = match_cursor_position(expected_cursor, expected_value, i, real_value);
if (match > best_match || (match == best_match && abs((int)expected_cursor - (int)i) < abs((int)expected_cursor - (int)best_cursor))) {
best_match = match;