summaryrefslogtreecommitdiff
path: root/editor/editor_help.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_help.cpp')
-rw-r--r--editor/editor_help.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 8c3569df07..43486a09a1 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -1429,14 +1429,15 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
bbcode = bbcode.replace("[/gdscript]", "[/codeblock]");
for (int pos = bbcode.find("[csharp]"); pos != -1; pos = bbcode.find("[csharp]")) {
- if (bbcode.find("[/csharp]") == -1) {
+ int end_pos = bbcode.find("[/csharp]");
+ if (end_pos == -1) {
WARN_PRINT("Unclosed [csharp] block or parse fail in code (search for tag errors)");
break;
}
- bbcode.erase(pos, bbcode.find("[/csharp]") + 9 - pos);
+ bbcode = bbcode.left(pos) + bbcode.substr(end_pos + 9); // 9 is length of "[/csharp]".
while (bbcode[pos] == '\n') {
- bbcode.erase(pos, 1);
+ bbcode = bbcode.left(pos) + bbcode.substr(pos + 1);
}
}
break;
@@ -1445,14 +1446,15 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
bbcode = bbcode.replace("[/csharp]", "[/codeblock]");
for (int pos = bbcode.find("[gdscript]"); pos != -1; pos = bbcode.find("[gdscript]")) {
- if (bbcode.find("[/gdscript]") == -1) {
+ int end_pos = bbcode.find("[/gdscript]");
+ if (end_pos == -1) {
WARN_PRINT("Unclosed [gdscript] block or parse fail in code (search for tag errors)");
break;
}
- bbcode.erase(pos, bbcode.find("[/gdscript]") + 11 - pos);
+ bbcode = bbcode.left(pos) + bbcode.substr(end_pos + 11); // 11 is length of "[/gdscript]".
while (bbcode[pos] == '\n') {
- bbcode.erase(pos, 1);
+ bbcode = bbcode.left(pos) + bbcode.substr(pos + 1);
}
}
break;