Syntax highlighter edge case

Certain actions involving nested double brackets confuse the syntax highlighter. I’ll lead with gifs.

28ee5a9bc672efb2793966bca2d37310b934ad1a.gif

4ba32673b784f6df6e8cb1703fbb13e11eaa10d2.gif

Repro steps:

1. Write a multi-line double-bracketed comment or string.

--[[
--]]
foo = bar -- colored normally

2. Change the nesting level of the terminal bracket so that it doesn’t match up with the starting bracket.

--[[
--]=]
foo = bar -- colored as a comment

Result: As you’d expect, all text following the string/comment is highlighted to match the color of the block because there’s no matching terminal to close the starting bracket. All good so far.

3. Change the starting bracket’s nesting level to match up with the terminal bracket’s new level.

--[=[
--]=]
foo = bar -- still colored as a comment, but should be colored normally
  • Expectations: Now that we have some properly closed brackets, the text from step 2 should revert to the same colors as before.
  • Reality: The text colors don’t update.
5 Likes