summaryrefslogtreecommitdiffstats
path: root/core/ustring.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/ustring.cpp')
-rw-r--r--core/ustring.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 32ef1eb5ff..ff7c8984fa 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -3057,12 +3057,11 @@ String String::world_wrap(int p_chars_per_line) const {
if (i-from>=p_chars_per_line) {
if (last_space==-1) {
ret+=substr(from,i-from+1)+"\n";
- from=i+1;
} else {
ret+=substr(from,last_space-from)+"\n";
- i=last_space;
- from=i+1;
+ i=last_space; //rewind
}
+ from=i+1;
last_space=-1;
} else if (operator[](i)==' ' || operator[](i)=='\t') {
last_space=i;