Collapsible Code Regions

Feedback Case Number:
#70015

Maybe this already exists and I cannot find it in help, but it would be nice if you could have collapsible code regions like what some other IDEs include. Yes comments are great but I use comments to indicate a section of code, and it can be hard to tell if another comment is defining the next section, a sub section, or a note.

1 Like

Hi @Travis_Edrington , welcome the the Forum !

What you describe is not an issue in Issues terms: it’s not a bug, you suggest Xojo to add a new functionality to the editor. Can’t recall if it’s called an idea or something else.

Hence why I have this in the Bugs and Feature Requests subfourm

Yes, this is what it is called.

So what led you thinking Travis mentioned it as an issue?

Maybe we can start with the beginning.

What is this “feature” ? (as I do not understand the above explanation)

Maybe an example (as text or graphic) will be more explicit…

This would be the same as having a code block in the IDE that equates to:

If True Then ' Start of a code block that is collapsible, but will always execute.
  ' Lots of code here
End If ' End of collapsible code block.

Current view when that block is collapsed:

EDIT: Ah, look at that! Already suggested and being discussed on the case. Nice.

1 Like

In Microsoft Visual Basic documentation it covers the same thing https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/directives/region-directive

OK. Now I understand the feature request.

But, I find strange that some people are crying because they cannot read the whole code and some others want to hide (more) parts of the code…:ukraine:

Am I going mad here, doesn’t the Xojo IDE Code editor already support code folding?

1 Like

Yes, I was thinking that too. So I wonder what @Travis_Edrington is talking about.

In visual studio you have something callad a
#region, you can define such a region and the fold that region.

I suppose that’s a bit more flexible or general than what Xojo has, but I would never use such a feature anyway - too much clutter. I only use the Xojo feature by accident.

1 Like

If you check out the ticket that was filed, the OP said they don’t care about the syntax, so we pointed out #if true then works the same. The request then evolved into “we want named regions.”

The more we pointed out this feature already exists, the more the request mutated. Since the request wasn’t clear and keeps mutating I got frustrated and gave up.

Correct. Yes Xojo supports code folding but that only applys to code blocks like IF statements and FOR/DO loops. I am suggesting a feature that allows you to make arbutary blocks of code that can be folded, like the #region in Visual Studio.

I’d rather they fixed bugs instead.

5 Likes

When I said I don’t care about the syntrax I mean I don’t care if it is some thing like #region from visual studio (which seems to be the only live example I can find), or #block, or Start. The problem with #if true then is that its confusing to an outside observer and it doesn’t stand out as this is a block of code like we are in a new section of a book.

To be fair when I was submitting this I was confused too as I was trying to make a feature request and it felt like I was doing a bug report.

Until Xojo comes with

#block
    //code
#endblock

you can do this to make it clear to others:

//This is a block of code, you can click on the left of #if to collapse/expand
#if true then 
  //code
#endif
//This is the end of the block of code

And if you use my reformat code script, you can do the conversion from #block to #if true then automatically, see ReplaceWords

Xojo really needs to preserve folding between saves first through before it gets into additional functionality on folding.

https://tracker.xojo.com/xojoinc/xojo/-/issues/11144
https://tracker.xojo.com/xojoinc/xojo/-/issues/14372

11 years and counting, it’s never too soon :wink:

3 Likes