Skip to content

Commit b28b619

Browse files
committed
fix: fix numbers not being highlighted and being eaten in some cases
1 parent 494e0f4 commit b28b619

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

utils/TextUtils.gd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const REGEX_PATTERN_FUNC = "(?<func>func)"
1212
# Regex pattern to find method calls (e.g. "draw(...)")
1313
const REGEX_PATTERN_METHOD_CALL = "(?<method_name>\\w[\\w\\d]*)(?<method_args>\\(.*?\\))"
1414
# Regex pattern for numbers (with no special characters on either side)
15-
const REGEX_PATTERN_NUMBER = "(?<number>[^#\\[\\]\\(\\)]?[0-9]++\\.?[0-9][^#\\[\\]\\(\\)]?)"
15+
const REGEX_PATTERN_NUMBER = "(?<number>\\d+(\\.\\d+)?)"
1616
const REGEX_SYMBOL = "(?<symbol>[a-zA-Z][a-zA-Z0-9_]+)"
1717

1818

@@ -62,6 +62,8 @@ static func bbcode_add_code_color(bbcode_text := "") -> String:
6262
colored_string += replaced.substr(current_index, last_closing_bracket_index)
6363
current_index = last_closing_bracket_index
6464

65+
if colored_string == "":
66+
colored_string = match_string
6567
colored_string = "[code]" + colored_string + "[/code]"
6668
bbcode_text.erase(index_offset, initial_length)
6769
bbcode_text = bbcode_text.insert(index_offset, colored_string)

0 commit comments

Comments
 (0)