Shown line after folding



I’ve been using atom for a while to edit a big markdown file. For such big file folding is of paramount importance. The package markdown-folder has done a great job for me:

But since 1.9.0 some has changed in the folding behaviour and now I can’t use atom for these long markdown files anymore. Now when I fold some text using the markdown-folder package or the selection folding the I do not get the first line of the folded section shown, I just get an empty line with the folding marker.
I’ve tried to find out in the 1.9.0 change log what has changed, but with no luck. I have done no atom development, I’m just a regular atom user, so I guess I’m missing something.
Anyway, keep up your great work with atom and I hope you can point me in the right direction. For the time beeing I’ll stay in 1.8.

Jose Blanca


I’ve downloaded both Atom 1.8.0 and Atom 1.9.8 and I’ve prepared a short Markdown Text to show the change in behaviour. In the screencasts I’ve selected the same text in both Atoms and I’ve run the command “Fold Selection”. You can see that in Atom 1.8.0 the first line, the line with the Markdown header is show after the folding, but in Atom 1.9.8 is not shown. I detected that behaviour for the first time in Atom 1.9.0.

In Atom 1.8.0:
(System says I can only upload one image. I’ll try to upload the 1.8.0 image in a following comment)

In Atom 1.9.8.

Any hint would be appreciated.

Jose Blanca


The behaviour in 1.8.0.


Yes, we changed how Fold Selection works so that you can fold arbitrary selections (including partial lines) instead of only whole lines. If you select to the end of the header line instead of the beginning of the header line, you’ll get the same behavior as before.


That sound like a reasonable change. The problem with it is that it has broken a package used to fold Markdown texts called markdown-folder.
I’d like to fix it, but I don’t have any experience coding Atom packages. Could you point me to the relevant bits of the selecting and folding APIs in other to fix it? I’ll also take a look that the original package source code.

Jose Blanca


I’m trying to fix the problem (although I don’t know javascript or coffeescprit).

I’ve been able to create an extension that folds and unfolds the markdown header of the current line.
But the markdown-folder extension is capable of a more complex behaviour. It can fold the subheaders within a header. To do it it cheks if the current header is currently folded using the method isFoldedAtBufferRow from the TextEditor class.

Now, the problem. I need to check if the start of a line is folded or not, but I don’t find in the API any method to do it. All methods refer to line row numbers, but with the new folding behaviour I’m folding only the last character of the header lines and I want to know if the first character is folded. I don’t know how to do that.

Jose Blanca


Finally I was able to replicate the funcionallity that I missed in a new package that works with Atom > 1.9. It does not has all the functionallity of the previous package and it might have some bug (take into account that I’m new to Atom hacking), but it is working for me. If anybody want to take a look at the code you can find it in a github repo called mardown-folding.

Jose Blanca


Hey, thanks for this!

The behavior of the markdown-folder package is not functional for helping me navigate through large markdown files. I fold at a heading and then have to guess what heading I folded. Your package is very helpful.

Mike Garrett