1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-10 13:00:37 +00:00

String: Remove erase method, bindings can't mutate String

This commit is contained in:
Rémi Verschelde
2021-11-11 09:08:08 +01:00
parent 171a69757f
commit 2beaae4b6f
10 changed files with 24 additions and 41 deletions

View File

@@ -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;