On 7 Oct 2019, at 16:31, Kyle Kirbatski wrote:

And try to code fold on the line "if ( !Array.isArraty(environment)) {“ then it ends up folding the entire function declaration.

How can I make this work as expected? I have a sneaky suspicion that this is a fatal flaw with TextMate.

It’s a limitation of how foldings are defined, as foldable lines are determined by a regular expression match.

So a line either starts a fold or stops a fold, it can’t do both, as the regular expression match is run against the full line, so TextMate wouldn’t know at what column the respective patterns think the folding should start/stop.

The Language Server Protocol has a command/extension to request folding ranges from a language server, so if TextMate gets support for LSP, it could make use of this to get better ranges, assuming the language server for the respective language supports it, as TextMate itself has no problem folding your code as desired (you can fold manually by selecting the contents of the braces and press F1).