[TxMt] Re: Broken code folding (javascript)

Allan Odgaard mailinglist at textmate.org
Mon Oct 14 07:54:04 UTC 2019


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).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macromates.com/textmate/attachments/20191014/bb735863/attachment.html>


More information about the TextMate mailing list