Section editor fold status on tiddlywiki update

hi @mohammad,

i was checking out updating from 5.2.1 to 5.2.2

but noticed that even if i selected all tiddlers to import (by unchecking and rechecking the “all tiddlers” import checkbox), section editor seemed to lose its fold status?

i am using the tweak mentioned in Section editor fold status now temporary, not good for long-form writing? i.e. foldstatus definition and change $:/temp prefix to $:/state prefix; but this did not seem to hold on tiddlywiki update (it works fine for normal use)

the state tiddlers themselves seem to be present and correct in the updated tiddlywiki i.e. the state tiddlers contain closed and seems to have the correct titles, and section editor was imported along with the other tiddlers (so the tweak for $:/state prefix is present)

once a section is manually closed, the state tiddler appears functionally identical (still contains “closed”) but now this particular state works again!

maybe the state tiddlers are not being read at startup in the updated tiddlywiki for some reason? or have i broken my section editor instance? source tiddlywiki is at http://makiaea.org

sorry i would attach the test tiddlywikis themselves but i think there is some restriction on the types of files we can attach?

not urgent at all, was just checking it out!

For updating TW and importing state tiddlers I think other experts and developers can give a better explanation here!

But just for testing purpose:

  • download an empty.html of TW 5.2.2
  • drag and drop your local TW (single html) over empty.html
  • save and reload

Lets see how everything works!

thanks so much for looking at this mohammad!

i’ve uploaded the files (after following your procedure above) and making sure to tick all the state tiddlers during the import

source: http://makiaea.org/00045/20210120makiaea.html

after drag-drop import to 5.2.2 empty.html: http://makiaea.org/00045/20220509test.html

unfortunately it shows the same behaviour:

e.g. for the tiddler

spices

there actually exists two(!) state tiddlers of the same title(please see below), one containing open and one containing closed (since i manually closed it after import for testing) named:

$:/state/section-editor/foldstate/spices/1

it seems like the updated tiddlywiki only respects newly created state tiddlers (even creating them with the same name as existing imported state tiddlers if they “already exist”)?

i did try searching talk.tiddlywiki and the gg forum for state tiddler import etc but couldn’t surface anything suitable – maybe importing state tiddlers just doesn’t import the right hash somehow? i tried Keeping track of fields. What are best practises? but don’t know enough to implement it yet

i’ve had a look at https://tiddlywiki.com/#StateMechanism but can’t see from the normal user interface where to find the hash it talks about; examining the two “identical” state tiddlers’ info, fields etc doesn’t show anything obvious – i’m guessing that’s where the problem is?

i.e. maybe the imported state tiddler has a mismatched hash somewhere in a hidden field, so it is not applied; and only a newly created state tiddler has the correct hash

ps i have command palette installed on both wikis so ctrl-p for search works if you want to use it

thanks again for looking mohammad, sorry for the trouble!

i think i figured out that i broke my copy of section editor somehow (in the past):

the only difference in the code i could find was

{"created":"20220409001606494","text":"open","title":"$:/state/section-editor/foldstate/spices/1","modified":"20220509174351667"}, {"created":"20220509174324770","title":"$:/state/section-editor/foldstate/spices/1 ","text":"closed","modified":"20220509174403201"},

that the title for the “duplicate” state actually had an extra trailing space in the title!

so

\define foldstatusTid() $:/state/section-editor/foldstate/$(source)$/$(counter)$ (trailing space)

must have been

\define foldstatusTid() $:/state/section-editor/foldstate/$(source)$/$(counter)$ (no trailing space)

for my case at some point.

i looked at Section Editor — create, edit, fold, manage sections for the code of $:/plugins/kookma/section/macros/definition and it seems the trailing space is default?

i think i upgraded to the newest version of section editor recently so it might have been corrected then (and i had been using a version i’d changed without the trailing space)

\define stateTid() $:/section-editor/state/$(source)$
\define editTid()  $:/section-editor/content/$(source)$/$(counter)$ 
\define foldstatusTid()  $:/temp/section-editor/foldstate/$(source)$/$(counter)$ 

(only the stateTid line has no trailing space in 1.1.0)

once i matched the definition to my existing status tiddlers they are all working :slight_smile: sorry for the false alarm!

the weird thing is that the state tiddlers seemed to be working in my original source wiki…

so i checked and they all had a trailing space

it seems the tiddlywiki import automatically removes trailing spaces from tiddler titles?

this is what broke my state tiddlers i think