Try to maintain folding state over modified text

Happy new year!

As I understand it, TP discards the folding state, if the document has been changed externally. For instance, I manage many TP files which Git and when I pull a new version TP displays it fully expanded. I would prefer a more generous approach, trying to keep the saved state if possible and discard it only if anything goes totally wrong.

Btw., when the document is open on pull, the folding state does not change - may be that could be starting point.

Kind regards,

Nils

As TaskPaper documents are plain text files, folding state can only be stored in extended attributes of a file, or in Apple’s user interface preservation API.

The retention or loss of extended attributes, and the contexts in which each occurs, depends more on operating system design, and on the behaviour of other applications, than on the design of TaskPaper.

As I understand it, TP discards the folding state, if the document has been changed externally.

It’s actually not TaskPaper that discards the state.

The first thing to explore, from the Terminal prompt, might be:

man xattr

(To read the documentation on the xattr command)

and you can see the storage of folding state by running xattr on a file written out by TaskPaper itself, rather than by some other application or utility.

For example, if I have a TaskPaper-written text file with the path:

/Users/houthakker/Notes/notes2020-01-06.taskpaper

then with the -l switch of xattr:

xattr -l ~/Notes/notes2020-01-06.taskpaper

I may see things like:

com.taskpaper.editor.defaultRestorableState.houthakker: {
    "hoistedID": "1945942400",
    "collapsedItemIDs": ["1149416613", "712709677", "3819108301", "2365024637"],
    "itemPathFilter": ""
}

Hi,

thank you for pointing this out. I took a look at the attributes and got a pretty long id list for all the collapsed items. So I see there will be absolutely no way to both maintain the state over external changes and having a document with valid id references.

Nils

1 Like