diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_help.cpp | 14 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 5 |
2 files changed, 9 insertions, 10 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; diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index a655420d27..a5088a5246 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1629,10 +1629,7 @@ void ScriptTextEditor::_color_changed(const Color &p_color) { } String line = code_editor->get_text_editor()->get_line(color_position.x); - int color_args_pos = line.find(color_args, color_position.y); - String line_with_replaced_args = line; - line_with_replaced_args.erase(color_args_pos, color_args.length()); - line_with_replaced_args = line_with_replaced_args.insert(color_args_pos, new_args); + String line_with_replaced_args = line.replace(color_args, new_args); color_args = new_args; code_editor->get_text_editor()->begin_complex_operation(); |