Merge branch 'master' into making-things-easy

Conflicts:
	.gitignore
	Rakefile
This commit is contained in:
Corey Johnson
2012-09-18 15:37:43 -07:00
203 changed files with 1727 additions and 3340 deletions

View File

@@ -9,13 +9,18 @@ EventEmitter = require 'event-emitter'
Range = require 'range'
AnchorRange = require 'anchor-range'
_ = require 'underscore'
fs = require 'fs'
module.exports =
class EditSession
@idCounter: 1
@deserialize: (state, project) ->
session = project.buildEditSessionForPath(state.buffer)
if fs.exists(state.buffer)
session = project.buildEditSessionForPath(state.buffer)
else
console.warn "Could not build edit session for path '#{state.buffer}' because that file no longer exists"
session = project.buildEditSessionForPath(null)
session.setScrollTop(state.scrollTop)
session.setScrollLeft(state.scrollLeft)
session.setCursorScreenPosition(state.cursorScreenPosition)

View File

@@ -119,8 +119,11 @@ class Project
bufferForPath: (filePath) ->
if filePath?
filePath = @resolve(filePath)
buffer = _.find @buffers, (buffer) -> buffer.getPath() == filePath
buffer or @buildBuffer(filePath)
if filePath
buffer = _.find @buffers, (buffer) -> buffer.getPath() == filePath
buffer or @buildBuffer(filePath)
else
else
@buildBuffer()

View File

@@ -102,7 +102,7 @@ class RootView extends View
changeFocus = options.changeFocus ? true
allowActiveEditorChange = options.allowActiveEditorChange ? false
unless editSession = @openInExistingEditor(path, allowActiveEditorChange)
unless editSession = @openInExistingEditor(path, allowActiveEditorChange, changeFocus)
editSession = @project.buildEditSessionForPath(path)
editor = new Editor({editSession})
pane = new Pane(editor)
@@ -110,12 +110,14 @@ class RootView extends View
if changeFocus
editor.focus()
else
@makeEditorActive(editor)
@makeEditorActive(editor, changeFocus)
editSession
openInExistingEditor: (path, allowActiveEditorChange) ->
openInExistingEditor: (path, allowActiveEditorChange, changeFocus) ->
if activeEditor = @getActiveEditor()
activeEditor.focus() if changeFocus
path = @project.resolve(path) if path
if editSession = activeEditor.activateEditSessionForPath(path)
@@ -124,7 +126,7 @@ class RootView extends View
if allowActiveEditorChange
for editor in @getEditors()
if editSession = editor.activateEditSessionForPath(path)
editor.focus()
@makeEditorActive(editor, changeFocus)
return editSession
editSession = @project.buildEditSessionForPath(path)
@@ -134,7 +136,11 @@ class RootView extends View
editorFocused: (editor) ->
@makeEditorActive(editor) if @panes.containsElement(editor)
makeEditorActive: (editor) ->
makeEditorActive: (editor, focus) ->
if focus
editor.focus()
return
previousActiveEditor = @panes.find('.editor.active').view()
previousActiveEditor?.removeClass('active').off('.root-view')
editor.addClass('active')