The following is observed in Stata 15.0 (Windows) (see screenshot below).
Stata is confused by an unmatched closing curly bracket included into the text of the program as part of a string constant. Interestingly it is not confused if the same is included as part of the quoted string, rather than compound-quoted string.
The problem manifests itself in absence of maroon coloring in line 8, and dysfunctional code folding from the point where the bracket occurred.
The problem was discovered in a large mata file, where a similar occurrence at the top of the file effectively renders region (folding) marks throughout the rest of the file inappropriately. The screenshot below is a trivial reproduction example.
While we are on the code folding, here is a wish for Stata 16: collapse to definitions hotkey in the doeditor. Collapse to definitions is a command to fold all code folds to the level of definition (basically hiding away the implementation of the programs in the screenshot below, but leaving the declarations). Ctrl+M,O in Visual Studio. I believe Scintilla has very powerful code folding control, so that should be possible as long as the declarations can be properly identified as such, thank you!
Best, Sergiy Radyakin

Stata is confused by an unmatched closing curly bracket included into the text of the program as part of a string constant. Interestingly it is not confused if the same is included as part of the quoted string, rather than compound-quoted string.
The problem manifests itself in absence of maroon coloring in line 8, and dysfunctional code folding from the point where the bracket occurred.
The problem was discovered in a large mata file, where a similar occurrence at the top of the file effectively renders region (folding) marks throughout the rest of the file inappropriately. The screenshot below is a trivial reproduction example.
While we are on the code folding, here is a wish for Stata 16: collapse to definitions hotkey in the doeditor. Collapse to definitions is a command to fold all code folds to the level of definition (basically hiding away the implementation of the programs in the screenshot below, but leaving the declarations). Ctrl+M,O in Visual Studio. I believe Scintilla has very powerful code folding control, so that should be possible as long as the declarations can be properly identified as such, thank you!
Best, Sergiy Radyakin
Code:
program define test display "}" display "a" end program define test display `"}"' display `"a"' end