adobe/brackets — pull request #2898 by peterflynn (2013-02-19 07:34:35+00:00)
Title: Remember selection/cursor and scroll position per file

This implements three related pieces of functionality:

* [Remember scroll/cursor position of files in working set across launches](https://trello.com/card/102-remember-scroll-cursor-position-of-files-in-working-set-across-launches-2/4f90a6d98f77505d7940ce88/339)
* [Remember scroll/cursor position of files NOT in working set, within session](https://trello.com/card/2-57-remember-scroll-cursor-position-of-files-not-in-working-set-within-session/4f90a6d98f77505d7940ce88/294) (info is forgotten when you quit or switch projects)
* When Esc cancels a Quick Open session, we restore the exact original scroll position instead of just restoring the cursor/selection and letting auto-scroll approximate the old pos.

In the process, I've added a "beforeAppClose" event and cleaned up the way DocumentManager persists info about the working set. Instead of listening to a wide variety of events (and using a guard flag to ignore cases where the events are spurious due to project switching), it now listens to "beforeAppClose".

There are two things that are a little unclean:
* "beforeProjectClose" is fired on ProjectManager (to pair with the existing "beforeProjectClose") but triggered by DocumentCommandHandlers since that's who owns the app shutdown process. Seemed like the best option, but still not ideal...
* EditorManager exposes two private methods for DocumentManager to get/set the remembered state related to the working set. IMHO the root issue is that EditorManager should really own the working set and its persistence, but instead DocumentManager owns it. (Especially true later if we have multiple windows, split views, etc.). Without wholesale moving all that stuff over, there's bound to be a little uncleanliness to the Editor/DocumentManager division of labor here.