Paragraphs delivered to UXP script are suddenly "invalid." Why?
I've written some JavaScript with the UXP facility to do some formatting. It works well... until I select one character too many. It's infuriating: The script iterates through all the paragraphs in a selection and does some styling; but midway through, the paragraphs are all deemed "invalid" by InDesign... but only if the selection goes beyond some invisible boundary.
And the start of the "invalid" paragraphs in the overall collection (in the selection) changes based on how many characters the selection goes beyond the arbitrary one. Every extra character seems to cause the invalid paragraphs to start one spot earlier in the overall collection.
Check this out:

The farther past the F in "for" the selection goes, the earlier the "invalid" paragraphs are encountered in the collection. Starting with "fo," the 50th paragraph in the selection is invalid. For every non-space additional character I include at the end, the earlier the selection's paragraphs get corrupted (49th, then 48th, and so forth).
Anybody ever see this kind of thing before? It has basically rendered scripting unusable for any kind of thorough processing.
