diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-09 16:12:57 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-09 16:12:57 +0100 |
commit | ab4a7b2b77625f7a97714e46aec896ba12e5caec (patch) | |
tree | e2d62863357904f0e0752db88cfe3d5241d5a255 /core | |
parent | 6fca54a81b0136c4fc7ecc07162b08003d75c4e4 (diff) | |
parent | 57e39d0ce9a31364dba6a6174cbfd5a0098d8962 (diff) |
Merge pull request #72547 from MewPurPur/string-split-fix
Fix String.split() with empty string and delimeter
Diffstat (limited to 'core')
-rw-r--r-- | core/string/ustring.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
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> String::split_spaces() const { Vector<String> String::split(const String &p_splitter, bool p_allow_empty, int p_maxsplit) const { Vector<String> ret; + + if (is_empty()) { + if (p_allow_empty) { + ret.push_back(""); + } + return ret; + } + int from = 0; int len = length(); |