One thing I miss from Textmate days was the possibility to save foldings, that is, the folding state is kept between sessions. Is this something that could be implemented in the future?
Yes, it would be great.
+1. I keep all the code folded, this sucks that it doesn’t save, and that no one has made a plugin for it. Any ideas on how to start that plugin? I could give it a shot.
I’ve created the barebones of a save-folds package, but just noticed the save-session package remembered the folds of open files when closing and reopening Atom so maybe somewhere to start? I’m testing my package at min but will post back if it works.
Can you share your package?
bump on this? I’m surprised no one else is begging for this. Should it be saved with the atom project manager plugin?
I’ve just been searching for a solution to this. I assume there is enough interest to justify creating an atom package?
From this thread, it sounds like it.
It would surely be really usefull!!!
i need this tooooo.
Assuming I can find the time to create a package, would people be okay using comments like so to indicate folding sections?
That would be language-specific, bloat files, and probably require a lot more work from the user (adding and deleting comments). It seems easier to me to use
TextEditor.isFoldedAtBufferRow() for each line in the buffer and save those values, then refold each of those lines when the package is activated.
Because of the language support within Atom, I would assume there is a way of identifying comments without being language specific.
This would be great. All session data is already stored in local storage, so it’s just a matter of adding a variable… There’s already a state for the fold, at runtime. We just need to find that place in the code, then hook a variable into the session storage instead of using a strictly-runtime variable. On each runtime load of the file, there might need to be a way to match the new fold instance with the variable in the project storage. Maybe it can just check if the current line matches the one from last time? But this would mean storing the fold lines in the storage. Maybe there’s another way, just throwing an idea out there.
Yeah, you can select by scope, but then you’d end up having to process the strings to remove the
<!-- -->s and
Have no more info to add than YES!! I am so happy someone is on this!
EDIT: Acctually I do. I Don’t think it is optimal to do the saving by comment… Better to use the variable Atom natively is using for folding
I think @trusktr is thinking about this the right way. I’m not familiar with atom dev apis, but I’m assuming we’ll have to save line numbers and fold info, file and project info (and not just file for performance reasons). Has someone or is someone willi to take a lead on this an start a repo?
Ah I missed @andythedev comment about giving this a go. Yeah the comment approach is no good. I for one could never get away with being able to push code with comments like that to production. This should be transparent.
I’m pretty sure the functionality isn’t there. I just checked marker-layer properties and there’s nothing promising. Bookmarks do not persist after closing tab.
We could maybe just save the whole buffer.getDisplayLayer().foldMarkerLayer object when destroying a buffer, and just give it back when reopened But I’ve never JSON’d anything before, so maybe I’ll let someone else experiment.