From 57e39d0ce9a31364dba6a6174cbfd5a0098d8962 Mon Sep 17 00:00:00 2001 From: VolTer Date: Wed, 1 Feb 2023 23:29:17 +0100 Subject: Fix String.split() with empty string and delimeter --- core/string/ustring.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'core/string') diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index b34d9f3271..1b3b070592 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -1157,6 +1157,14 @@ Vector String::split_spaces() const { Vector String::split(const String &p_splitter, bool p_allow_empty, int p_maxsplit) const { Vector ret; + + if (is_empty()) { + if (p_allow_empty) { + ret.push_back(""); + } + return ret; + } + int from = 0; int len = length(); -- cgit v1.2.3