documents.length doesn't update within a script running as a registerAsBackgroundScript, after a new file is open.
i've written the following script:
Periodic auto-save all documents under a new name.
the script is started when TXS starts (triggered as ?txs-start).
its registerAsBackgroundScript, and reactivates itself using setTimeout to perform periodic saves.
The script uses documents.length to know how many open documents there are, and iterate over them
When TXS starts (and the script starts) there is one open document, and indeed documents.length=1.
But after I open another file (the second file is opened after TXS has started already), the call to documents.length within the script still returns 1.
If I sample documents.length manually (after two files are open), it returns 2.
So it seems that the documents object within the script with registerAsBackgroundScript is not updated correctly.
any ideas?
to see that behavior, try the next minimal working example script:
1) run the script.
2) wait for a message print, compare the actual number of open documents, with the message. they should be equal.
3) open a new document (and leave the previous open).
4) wait for another message. the reported number doesn't change, and it is no longer the real number of open documents.
fixed in repository