From b28b619f86207369bd99b20d03056e2749861379 Mon Sep 17 00:00:00 2001 From: Nathan Lovato <12694995+NathanLovato@users.noreply.github.com> Date: Mon, 26 Sep 2022 13:47:25 +0200 Subject: [PATCH] fix: fix numbers not being highlighted and being eaten in some cases --- utils/TextUtils.gd | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/TextUtils.gd b/utils/TextUtils.gd index 8f7e6a83..499d521d 100644 --- a/utils/TextUtils.gd +++ b/utils/TextUtils.gd @@ -12,7 +12,7 @@ const REGEX_PATTERN_FUNC = "(?func)" # Regex pattern to find method calls (e.g. "draw(...)") const REGEX_PATTERN_METHOD_CALL = "(?\\w[\\w\\d]*)(?\\(.*?\\))" # Regex pattern for numbers (with no special characters on either side) -const REGEX_PATTERN_NUMBER = "(?[^#\\[\\]\\(\\)]?[0-9]++\\.?[0-9][^#\\[\\]\\(\\)]?)" +const REGEX_PATTERN_NUMBER = "(?\\d+(\\.\\d+)?)" const REGEX_SYMBOL = "(?[a-zA-Z][a-zA-Z0-9_]+)" @@ -62,6 +62,8 @@ static func bbcode_add_code_color(bbcode_text := "") -> String: colored_string += replaced.substr(current_index, last_closing_bracket_index) current_index = last_closing_bracket_index + if colored_string == "": + colored_string = match_string colored_string = "[code]" + colored_string + "[/code]" bbcode_text.erase(index_offset, initial_length) bbcode_text = bbcode_text.insert(index_offset, colored_string)