Fix bug where edit sessions were not properly restored on refresh

This commit is contained in:
Nathan Sobo 2012-06-27 07:53:32 -06:00
parent 086b33f606
commit 5b11762989
2 changed files with 7 additions and 8 deletions

View File

@ -48,7 +48,8 @@ describe "Editor", ->
rootView.height(8 * editor.lineHeight) rootView.height(8 * editor.lineHeight)
rootView.width(50 * editor.charWidth) rootView.width(50 * editor.charWidth)
editor.setCursorScreenPosition([5, 20]) editor.edit(rootView.project.open('two-hundred.txt'))
editor.setCursorScreenPosition([5, 1])
editor.scrollTop(1.5 * editor.lineHeight) editor.scrollTop(1.5 * editor.lineHeight)
editor.scrollView.scrollLeft(44) editor.scrollView.scrollLeft(44)
@ -60,11 +61,11 @@ describe "Editor", ->
expect(editor.serialize).toHaveBeenCalled() expect(editor.serialize).toHaveBeenCalled()
expect(Editor.deserialize).toHaveBeenCalled() expect(Editor.deserialize).toHaveBeenCalled()
expect(newEditor.buffer).toBe editor.buffer expect(newEditor.buffer).toBe editor.buffer
expect(newEditor.getCursorScreenPosition()).toEqual editor.getCursorScreenPosition() expect(newEditor.getCursorScreenPosition()).toEqual editor.getCursorScreenPosition()
expect(newEditor.editSessions[0]).toEqual(editor.editSessions[0]) expect(newEditor.editSessions).toEqual(editor.editSessions)
expect(newEditor.editSessions[0]).not.toBe(editor.editSessions[0]) expect(newEditor.activeEditSession).toEqual(editor.activeEditSession)
expect(newEditor.getActiveEditSessionIndex()).toEqual(editor.getActiveEditSessionIndex())
newEditor.height(editor.height()) newEditor.height(editor.height())
newEditor.width(editor.width()) newEditor.width(editor.width())

View File

@ -48,10 +48,8 @@ class Editor extends View
@deserialize: (state, rootView) -> @deserialize: (state, rootView) ->
editSessions = state.editSessions.map (state) -> EditSession.deserialize(state, editor, rootView) editSessions = state.editSessions.map (state) -> EditSession.deserialize(state, editor, rootView)
editor = new Editor(editSession: editSessions[state.activeEditSessionIndex], mini: state.mini)
editSession = editSessions[state.activeEditSessionIndex] editor.editSessions = editSessions
editor = new Editor(editSession: editSession, mini: state.mini)
editor.editSession = editSessions
editor.isFocused = state.isFocused editor.isFocused = state.isFocused
editor editor