Skip to content

Commit

Permalink
fix: fix numbers not being highlighted and being eaten in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanLovato committed Sep 26, 2022
1 parent 494e0f4 commit b28b619
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion utils/TextUtils.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const REGEX_PATTERN_FUNC = "(?<func>func)"
# Regex pattern to find method calls (e.g. "draw(...)")
const REGEX_PATTERN_METHOD_CALL = "(?<method_name>\\w[\\w\\d]*)(?<method_args>\\(.*?\\))"
# Regex pattern for numbers (with no special characters on either side)
const REGEX_PATTERN_NUMBER = "(?<number>[^#\\[\\]\\(\\)]?[0-9]++\\.?[0-9][^#\\[\\]\\(\\)]?)"
const REGEX_PATTERN_NUMBER = "(?<number>\\d+(\\.\\d+)?)"
const REGEX_SYMBOL = "(?<symbol>[a-zA-Z][a-zA-Z0-9_]+)"


Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b28b619

Please sign in to comment.