Preserve buffer contents for unsaved files when reloading

This commit is contained in:
Mutwin Kraus
2013-03-25 20:16:22 +01:00
committed by Nathan Sobo
parent 9a8fd062c4
commit 693d8258ad
4 changed files with 16 additions and 1 deletions

View File

@@ -17,6 +17,8 @@ class EditSession
@deserialize: (state) ->
if fs.exists(state.buffer)
session = project.buildEditSession(state.buffer)
else if state.unsavedState
session = project.buildEditSessionFromState(state.unsavedState)
else
console.warn "Could not build edit session for path '#{state.buffer}' because that file no longer exists" if state.buffer
session = project.buildEditSession(null)
@@ -92,6 +94,7 @@ class EditSession
scrollTop: @getScrollTop()
scrollLeft: @getScrollLeft()
cursorScreenPosition: @getCursorScreenPosition().serialize()
unsavedState: @buffer.getText() if !@buffer.fileExists()
copy: ->
EditSession.deserialize(@serialize(), @project)