[Lazarus] Folding ?

Michael Van Canneyt michael at freepascal.org
Sun Feb 19 21:12:24 CET 2023

On Sun, 19 Feb 2023, Martin Frb wrote:

> On 19/02/2023 19:06, Michael Van Canneyt wrote:
>> On Sun, 19 Feb 2023, Martin Frb via lazarus wrote:
>>> On 19/02/2023 12:28, Michael Van Canneyt via lazarus wrote:
>>>> Hi,
>>>> Is it possible to enable/disable code folding on a per-language basis  ?
>>> No, or only in the way you described below. Or by changing the source in 
>>> each highlighter, and make the pretend they don't fold.
>> That seems a strange way. Since folding can be globally switched on and 
>> off, it should also be
>> possible to switch it on/off on a language basis.
> Well, it just hasn't been implemented. There is no reason not to add it, if 
> someone wants to do it.
> To entertain my lack of imagination: What is the issue, if e.g. Pascal shows 
> fold indicators, and you just don't use them?

For starters, some people think adding

{%region /fold}

to the code is a good idea. I think not.

Secondly, I sometimes inadvertently click on the fold markers.

The above 2 reasons are why I disabled it. Also, I think that if you need
folding in Pascal, your code is not very well structured. As a general rule,
I think a procedure may not occupy more than 50 lines. If you adhere to
that, folding is simply not needed.

(strictly my personal opinion)

>>> In any case, there also remains the "fold selected lines" folding.
>> That would defeat the purpose. I use the folding to see if the HTML tags 
>> are closed properly without having
>> to select them.
> You don't have to select them.
> If you do select text, the gutter will show an additional fold (actually 
> "hide") symbol, allowing you to collapse whatever text is selected.
> Btw, folding may not be the best way to check for correct html nesting.
> IIRC, the highlighter tries to find a matching-name closing tag, even if that 
> means to skip other tags.

No doubt. But there are other uses: in large html structures (HTML can be
very verbose in some CSS frameworks, there is no way around it) , 
it helps to be able to see the larger structure.

Ideally, the fold indicators are also not visible in HTML/XML, 
but I can simply right-click a div and ask to collapse/expand that div.


More information about the lazarus mailing list