diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2019-06-19 12:43:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-19 12:43:46 +0200 |
commit | 2b52cd3e5c82bfb21774f8f850e2724da2baf234 (patch) | |
tree | f14b4d4260800b99635a6e1f2555a38d9ad38733 /core/ustring.cpp | |
parent | bb0aeb48741033f80f7576bd138189931ffbaa62 (diff) | |
parent | 0b8a785539ce7823855944aeff33aad3773aad6a (diff) | |
download | redot-engine-2b52cd3e5c82bfb21774f8f850e2724da2baf234.tar.gz |
Merge pull request #28648 from KoBeWi/substr-1
Make second parameter of substr optional
Diffstat (limited to 'core/ustring.cpp')
-rw-r--r-- | core/ustring.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp index 35b817b1d2..686aa6f8e3 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -2331,6 +2331,9 @@ String String::insert(int p_at_pos, const String &p_string) const { } String String::substr(int p_from, int p_chars) const { + if (p_chars == -1) + p_chars = length() - p_from; + if (empty() || p_from < 0 || p_from >= length() || p_chars <= 0) return ""; |