Information on folding state

I notice that FT files are sometimes opened in the same folding state as the one in which they were last closed (after editing). Where is the folding state information, i.e. which headings are folded, stored? It can’t be in the FT file itself because that is just plain text, right? This is an issue for me because I use FT files to store sensitive information and I don’t want fragments of it lying around the file system.

FT files are indeed plain text files, but the OS X filesystem allows each file (even text files) to have some metadata.

To see the metadata (including folding state) in a particular file, use Terminal.app to cd to a folder containing a saved FT file and use a command line like:

xattr -l myfile.txt

Here is the metadata for an FT text file saved in a folded state:

com.apple.TextEncoding: utf-8;134217984 com.foldingtext.editorstate: {"jsonFolds":[{"from":{"line":1,"ch":12},"to":{"line":4,"ch":7},"isManual":true},{"from":{"line":5,"ch":12},"to":{"line":8,"ch":7},"isManual":true},{"from":{"line":9,"ch":12},"to":{"line":12,"ch":7},"isManual":true}],"options":{"showListBullets":false,"continuousSpellChecking":false,"wrapToColumn":120},"nodePath":"///*"} com.foldingtext.editorstate.contentsyncdate: 2014-07-30 07:24:01 +0000

As you can see, the folding is specified in terms of line numbers rather than line texts.

PS file systems vary (across family and time) in the set of core and extended file attributes while they use and support. (Not all of the attributes which a Finder window can display

would survive the transfer of a file to MS Windows, for example) and not even all of the tools on an OS X system know about or fully support all extended attributes, so there are various ways in which syncing etc might remove the folding state info of an FT file.

Brett Terpstra recently discussed related issues in connection with making sure that tag metadata doesn’t get lost:

http://brettterpstra.com//2014/07/04/how-to-lose-your-tags/


and for a bit of history and technical detail on file system metadata in OS X:
http://arstechnica.com/apple/2013/10/os-x-10-9/9/

Thanks for the wonderfully complete reply! As a result, I’ll store my sensitive FT files in an encrypted disk image: that way also the metadata will be encrypted.