adventuregamestudio/ags — pull request #220 by monkey0506 (2014-12-28 06:42:59+00:00)
Title: Fixed incorrect ordering when inserting an item into a FolderListHybrid

**Issue:** When inserting an item into a FolderListHybrid (specifically, the ScriptFolders collection backing a ScriptsAndHeaders object), the *folder* collection does not accurately reflect the same ordering as the *items* collection. This can later lead to incorrect ordering overall, for example, when calling RePopulateTreeView which references the ordering of the *folder* collection.

*Example:*

When calling ScriptsAndHeaders.AddAt(script, 0), the ScriptsAndHeaders collection will show the newly inserted object at the top of the list. The project tree will not immediately refresh. When then calling RePopulateTreeView **or** adding/renaming a script in the Scripts branch of the project pane, the script previously inserted at the *top* of the list will appear at the bottom of the list.

Similarly, ScriptsAndHeaders.MoveScriptAndHeaderUp and MoveScriptAndHeaderDown are reflected in the ScriptsAndHeaders object, but the ordering is lost the next time the project tree is repopulated.

**Proposed solution:** Have the underlying *folder* collection observe the same logical ordering as the *items* collection.

This warrants some scrutiny for any overlooked side-effects, but as far as I can tell, this works properly while respecting the folder/list hybrid structure.