summaryrefslogtreecommitdiffstats
path: root/core/string
diff options
context:
space:
mode:
Diffstat (limited to 'core/string')
-rw-r--r--core/string/print_string.cpp2
-rw-r--r--core/string/ustring.cpp9
2 files changed, 7 insertions, 4 deletions
diff --git a/core/string/print_string.cpp b/core/string/print_string.cpp
index 7b90710308..dcdde3c175 100644
--- a/core/string/print_string.cpp
+++ b/core/string/print_string.cpp
@@ -164,6 +164,8 @@ void __print_line_rich(String p_string) {
p_string_ansi = p_string_ansi.replace("[/fgcolor]", "\u001b[39;49m");
}
+ p_string_ansi += "\u001b[0m"; // Reset.
+
OS::get_singleton()->print_rich("%s\n", p_string_ansi.utf8().get_data());
_global_lock();
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp
index 49c7ead423..12e6423724 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -4281,12 +4281,13 @@ String String::pad_zeros(int p_digits) const {
begin++;
}
- if (begin >= end) {
+ int zeros_to_add = p_digits - (end - begin);
+
+ if (zeros_to_add <= 0) {
return s;
+ } else {
+ return s.insert(begin, String("0").repeat(zeros_to_add));
}
-
- int zeros_to_add = p_digits - (end - begin);
- return s.insert(begin, String("0").repeat(zeros_to_add));
}
String String::trim_prefix(const String &p_prefix) const {