diff options
| author | Marco Melorio | 2017-04-23 23:03:16 +0200 |
|---|---|---|
| committer | Rémi Verschelde | 2017-05-26 18:47:23 +0200 |
| commit | b0d2b46efbac404dc71f255e85cc3f2d58520719 (patch) | |
| tree | 1799bace2bdc603d4a68e99e9ef7ba4033278d44 | |
| parent | fec8e2549ce3a53381bee781ba5e11224a31e64b (diff) | |
| download | godot-b0d2b46efbac404dc71f255e85cc3f2d58520719.tar.gz godot-b0d2b46efbac404dc71f255e85cc3f2d58520719.tar.zst godot-b0d2b46efbac404dc71f255e85cc3f2d58520719.zip | |
Update snake_case splitting
(cherry picked from commit 4677c0fbb882417bc9760c64ef730e454a0922ef)
| -rw-r--r-- | core/ustring.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp index f2c4c37db..070db5cf8 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -482,14 +482,16 @@ String String::camelcase_to_underscore(bool lowercase) const { for (size_t i = 1; i < this->size(); i++) { bool is_upper = cstr[i] >= A && cstr[i] <= Z; + bool is_number = cstr[i] >= '0' && cstr[i] <= '9'; bool are_next_2_lower = false; bool was_precedent_upper = cstr[i - 1] >= A && cstr[i - 1] <= Z; + bool was_precedent_number = cstr[i - 1] >= '0' && cstr[i - 1] <= '9'; if (i + 2 < this->size()) { are_next_2_lower = cstr[i + 1] >= a && cstr[i + 1] <= z && cstr[i + 2] >= a && cstr[i + 2] <= z; } - bool should_split = ((is_upper && !was_precedent_upper) || (was_precedent_upper && is_upper && are_next_2_lower)); + bool should_split = ((is_upper && !was_precedent_upper && !was_precedent_number) || (was_precedent_upper && is_upper && are_next_2_lower) || (is_number && !was_precedent_number)); if (should_split) { new_string += this->substr(start_index, i - start_index) + "_"; start_index = i; |
