Skip to content

Commit ea9660e

Browse files
committed
Fix usage of String.left()
1 parent 8c2beee commit ea9660e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

core/string/ustring.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ const char32_t *String::get_data() const {
939939
}
940940

941941
void String::erase(int p_pos, int p_chars) {
942-
*this = left(p_pos) + substr(p_pos + p_chars, length() - ((p_pos + p_chars)));
942+
*this = left(MAX(p_pos, 0)) + substr(p_pos + p_chars, length() - ((p_pos + p_chars)));
943943
}
944944

945945
String String::capitalize() const {

editor/editor_inspector.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -1824,7 +1824,13 @@ void EditorInspector::update_tree() {
18241824
}
18251825
}
18261826

1827-
String path = basename.left(basename.rfind("/"));
1827+
String path;
1828+
{
1829+
int idx = basename.rfind("/");
1830+
if (idx > -1) {
1831+
path = basename.left(idx);
1832+
}
1833+
}
18281834

18291835
if (use_filter && filter != "") {
18301836
String cat = path;

0 commit comments

Comments
 (0)