Syntax highlighter does not handle changes between different number = properly for long comments and long strings


In Lua, a long comment is made with --[[ Comment here ]]
It can also be made with --[=[ ]=], or --[======[ ]======], or any number of = signs.
This allows for nesting comments within each other, so --[=[ --[[ ]] ]=] is valid, while --[[ --[[ ]] ]] is not.

Similarly, there are long strings in Lua. These can be made with [[ ]], [=[ ]=], [===[ ]===], etc., and follow similar nesting rules to long comments.

Studio does not handle switching between different numbers of = properly in either case.

It’s easiest to understand the videos, so I’ll post those first:

Videos, click to expand

This bug occurs under the following conditions:

  • There is already a long comment/string present
  • The long comment/string is changed from any number of = to any other number of =
  • OR A long comment/string with a different number of = is added to enclose an existing comment/string

When this occurs, the section after the long comment/string, or after the inner/enclosed long comment/string, will be improperly highlighted. It will either be highlighted as a comment/string when it should not, or vice versa, depending on if that section was going from enclosed -> unenclosed or vice versa.

This bug only occurs when something is changed; the initial highlighting pass-through does it all perfectly, which can be seen when I cut/paste to have it re-check the whole section.


Possible duplicate/extension of this?

1 Like

Looks like it. Didn’t think such an obscure bug would have already been reported :man_shrugging:

Would make sense to merge the threads then.