Folding behavior seems wrong

If you have the following code:

if(1){
	do something
}else{
	do something else
}

and attempt to fold it by clicking the margin arrow at the first line you get

if(1){...
	do something else
}

Which seems wrong because it now looks like a single logic statement, not one with additional checks. You would expect it to fold like this…

if(1){...
...
}else{
	do something else
}

Or at least it should fold like this to show the steps of the logic statement:

if(1){...
}else{...

Also, if you fold the else line first and THEN fold the if line you get something completely different:

if(1){... ...

Which is confusing. So I have taken to writing my statements like this

if(1){
	do something
}
else{
	do something else
}

to give me the ability to fold like this

if(1){...
else{...

Has any one else noticed/experienced this? Does anyone care?

Someone do care.
The development of tree-sitter was pushed to bring changes.

Switch settings / core / tree sitter parser -> true
Restart Atom and check what does C++ language deliver now.

ok I will try that.

But shouldn’t this “just work” out of the box?

Also if you don’t mind, where do I “Switch settings / core / tree sitter parser -> true”?

There were 12K references to the word “parser” in the atom config folder and the Preferences pane has no mention of it.

So the folding of code in this free open source application does not work out-of-the-box as expected. Are you going to offer financial support to volunteers or make changes yourself or construct a package for us? Or move to Microsoft’s Code?

Personally I have no way to motivate others to do changes for me for free. I work around the problem until I win the lottery to finance some projects. :wink:



I kind of like this idea:

So the folding of code in this free open source application does not work out-of-the-box as expected. Are you going to offer financial support to volunteers or make changes yourself or construct a package for us? Or move to Microsoft’s Code?

Wow, negative much?

The objective of open-source collaboration is to make software as tight and elegantly-coded as it can be for the sake of doing something good. If you want to start judging these efforts on a “is it fiscally logical” basis, that is a completely different forum. I’m just pointing out something that I think others might want to know about and MAYBE improve for the sake of the project.

I have no way to motivate others to do changes for me for free

Don’t worry, no one expects you to motivate anyone, or fix anything, or do or say anything, especially if you feel it puts you out. Now THAT’S capitalism.

I’m not able to reproduce the behaviour in the first place. This is what I get when I copy and paste the code, set the language to C++, and click the fold arrow on line 1
image

Edit: I do see it when I revert to the old TextMate grammar. But they are no longer supported in cases when Tree-sitter is available. I don’t know why it is not enabled for your project, as it should be on by default and most people will never have to worry about any of this.

@Aerijo Strange, I have the noted behavior with or without tree-sitter enabled.

If you open the grammar selector, what grammar is picked and is it labelled Tree-sitter?

One of those should have a green tick next to it, meaning it’s the active grammar.

That was not the aim.


RE: Tree-sitter
Give Atom a clean restart after making a setting change.
Thereafter the difference that tree-sitter brings should be visible.

Confirm the change:

  1. Put the cursor inbetween some code
  2. Triggering from the command-pallet (Log Cursor Scope):
    image

Same thing after restart. Here is the “Log Cursor Scope” result:

How inconvenient. the built-in PHP grammar does not have a tree-sitter.
image

Look at the picture you left here 16hours ago. The grammars marked with green has a tree-sitter parser available. PHP does not. Surprising - PHP is tough on a parser and tree sitter should solve many “Atom’s handling of PHP” issues (like long code lines). There may be someone who developed something.


Feel welcome to code a short C++ piece and see what the aim is. Speak your mind if the idea is what you expect; hoping maintainers happen on these notes.

Hmm… ok. I don’t know C++ so I guess I am not much help!

I appreciate your efforts.