Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Remember selection/cursor and scroll position per file #2898

Merged
merged 4 commits into from
Feb 20, 2013

Conversation

peterflynn
Copy link
Member

This implements three related pieces of functionality:

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.

sessions, and of ALL files within a single session.

Simplify how DocumentManager saves working set state via a new
"beforeAppClose event". There's one ugly bit, a hack in EditorManager.
_restoreEditorViewState() to get around some CM API fragility.

Also save & restore scroll pos more precisely in Quick Open when user
closes it via Esc. Remove some vestiges of the very early, incomplete &
disabled code that dynamically previewed documents as you type. Plus small
cleanup in ModalBar for clarity.
…oll-pos

* origin/master: (236 commits)
  Update README.md
  Update README.md
  Update README.md
  Clarified comment
  Change string literals for resizeEditor() arg to constants
  Cleaned up refresh code and made it so we always refresh after showing the editor. Addresses some cases in #2782.
  Update CodeMirror SHA. For real this time.
  Update CodeMirror SHA
  Update CodeMirror SHA to brackets-sprint20 branch, which contains a temporary cherry-pick of a fix from upstream and avoids other fixes we don't want yet.
  Update CONTRIBUTING.md
  fix exception when opening empty folder and file open
  Remove extra divider from help menu.
  Reverting to old screenshot since the styling of the new screenshot doesn't match the (reverted) background.
  Updated de to match en Getting Started CSS
  dimgray background
  Turn off newline creation when autoclosing tags
  Set text cursor.
  Update comments.
  Only skip refresh if the width hasn't changed
  prettied it up a bit
  ...

Conflicts:
	src/editor/EditorManager.js
	src/search/QuickOpen.js
@ghost ghost assigned jasonsanjose Feb 19, 2013
@jasonsanjose
Copy link
Member

Reviewing

// Give everyone a chance to save their state - but don't let any problems block
// us from quitting
try {
$(ProjectManager).trigger("beforeAppClose");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this should be triggerHandler?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, yep. I think the two behave the same in cases like this, but all our other code has clearly standardized on trigger()...

@jasonsanjose
Copy link
Member

Looks good. Mostly minor comments.

@peterflynn
Copy link
Member Author

@jasonsanjose: changes pushed

@jasonsanjose
Copy link
Member

Looks good. Merging.

jasonsanjose added a commit that referenced this pull request Feb 20, 2013
Remember selection/cursor and scroll position per file
@jasonsanjose jasonsanjose merged commit ec8aafd into master Feb 20, 2013
@jasonsanjose jasonsanjose deleted the pflynn/preserve-scroll-pos branch February 20, 2013 17:30
@peterflynn
Copy link
Member Author

Sweet, thanks for the review!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants