tl;dr: moveItems() scrambles item order on first use.
Working under Mojave with the latest OO release, if I make a simple new outline like this…
- A
- B
- C
- D
- E
- F
- G
- H
…then select the C, D, E and F rows before executing this in the console window…
moveItems(document.editors[0].selection.items, rootItem.end)
…those rows do get moved to the bottom, but in scrambled (not simply backward) order, which is both a surprise and a problem.
The rows maintain their selected state, so if I then execute this…
moveItems(document.editors[0].selection.items, rootItem.beginning)
…the rows move to the top, as expected, and do not change order again–that is, they stay in the same scrambled order.
If I then move them back to the bottom, the same results–they keep the same scrambled order they inherited when I moved them the first time.
This smells like a bug, though perhaps my expectations are the problem.
Any thoughts on how to use moveItems() without corrupting item order?