Xcode hold the fold?

Is there any way that code folding can be persistent between coding sessions? Yes, I know I can fold all methods with a shortcut - not looking for that. I like the methods I previously folded stay that way until I unfold them myself.

Folding was introduced in Xcode 8 I believe, now we're at 13. Is about time it is able to save folding state, no?

I tested in Xcode 13.2.1:

  • Swift code
  • folded a method
  • quit Xcode or just close the project
  • reopen project

-> method stays folded

But bizarrely:

  • folded another method

-> does not reopen folded.

  • unfolded the first, quit

-> It reopens folded !!!!

Now, I made a change in the method (like adding a space after an = sign) and change fold state. -> It is kept on closing and reopening. -> I can modify in a second method ; fold state is saved only if I made a change.

So looks like fold state is saved (only?) when you made a change in the method.

Could you test also ?

I think it is worth a bug report.

Oh hey, hmm. Not quite sure I follow you're testing method but I did notice that after I do a fold, that file must be saved. if the file has no changes (only a fold), it isn't actually saved, making a simple change (add a space somewhere) and saving seems to work; reopening the project now has the methods still folded.

I see now what trips me up; since I have a few tabs open with a collection of files, some tabs have the same file open but apparently operate on a different view. I.e., folding methods in one does not fold them equally in the other. That is not necessarily bad (I can understand why you want to have different views of the same file) but leads to confusion whereas it pertains to a method's/section folded state.

This is soooo desperately needed!! No one knows how to fold my code like I do.

Xcode hold the fold?
 
 
Q