summaryrefslogtreecommitdiffstats
path: root/core/ustring.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2019-06-19 12:43:46 +0200
committerGitHub <noreply@github.com>2019-06-19 12:43:46 +0200
commit2b52cd3e5c82bfb21774f8f850e2724da2baf234 (patch)
treef14b4d4260800b99635a6e1f2555a38d9ad38733 /core/ustring.cpp
parentbb0aeb48741033f80f7576bd138189931ffbaa62 (diff)
parent0b8a785539ce7823855944aeff33aad3773aad6a (diff)
downloadredot-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.cpp3
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 "";