From f4300b8cab73ffa20cd3e20585faee4872436f8e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki & Nathan Sobo Date: Wed, 26 Jun 2013 14:06:45 -0600 Subject: [PATCH] Fix specs due to scrollTop/Left becoming methods on EditSession --- spec/app/editor-spec.coffee | 12 ++++++------ spec/app/pane-spec.coffee | 4 ++-- src/app/edit-session.coffee | 4 +++- src/app/editor.coffee | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index e3d173300..3905e58ca 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -124,7 +124,7 @@ describe "Editor", -> previousScrollTop = editor.scrollTop() previousScrollLeft = editor.scrollLeft() - newEditSession.scrollTop = 120 + newEditSession.setScrollTop(120) newEditSession.setSelectedBufferRange([[40, 0], [43, 1]]) editor.edit(newEditSession) @@ -214,18 +214,18 @@ describe "Editor", -> expect(editor.scrollTop()).toBe 50 it "sets the new scroll top position on the active edit session", -> - expect(editor.activeEditSession.scrollTop).toBe 0 + expect(editor.activeEditSession.getScrollTop()).toBe 0 editor.scrollTop(123) - expect(editor.activeEditSession.scrollTop).toBe 123 + expect(editor.activeEditSession.getScrollTop()).toBe 123 describe ".scrollHorizontally(pixelPosition)", -> it "sets the new scroll left position on the active edit session", -> editor.attachToDom(heightInLines: 5) setEditorWidthInChars(editor, 5) - expect(editor.activeEditSession.scrollLeft).toBe 0 + expect(editor.activeEditSession.getScrollLeft()).toBe 0 editor.scrollHorizontally(left: 50) - expect(editor.activeEditSession.scrollLeft).toBeGreaterThan 0 - expect(editor.activeEditSession.scrollLeft).toBe editor.scrollLeft() + expect(editor.activeEditSession.getScrollLeft()).toBeGreaterThan 0 + expect(editor.activeEditSession.getScrollLeft()).toBe editor.scrollLeft() describe "editor:attached event", -> it 'only triggers an editor:attached event when it is first added to the DOM', -> diff --git a/spec/app/pane-spec.coffee b/spec/app/pane-spec.coffee index b398df12d..923681f4a 100644 --- a/spec/app/pane-spec.coffee +++ b/spec/app/pane-spec.coffee @@ -679,11 +679,11 @@ describe "Pane", -> expect(pane.itemForUri(editSession2.getUri())).toBe editSession2 describe "serialization", -> - it "can serialize and deserialize the pane and all its serializable items", -> + it "can serialize and deserialize the pane and all its items", -> newPane = deserialize(pane.serialize()) expect(newPane.getItems()).toEqual [view1, editSession1, view2, editSession2] - it "restores the active item on deserialization if it serializable", -> + it "restores the active item on deserialization", -> pane.showItem(editSession2) newPane = deserialize(pane.serialize()) expect(newPane.activeItem).toEqual editSession2 diff --git a/src/app/edit-session.coffee b/src/app/edit-session.coffee index 411043da7..6d5379169 100644 --- a/src/app/edit-session.coffee +++ b/src/app/edit-session.coffee @@ -48,6 +48,8 @@ class EditSession @state = telepath.Document.fromObject deserializer: 'EditSession' version: @constructor.version + scrollTop: 0 + scrollLeft: 0 cursorScreenPosition = [0, 0] @softTabs = @buffer.usesSoftTabs() ? softTabs ? true @@ -1296,7 +1298,7 @@ class EditSession abort: -> @buffer.abort() inspect: -> - JSON.stringify @serialize() + JSON.stringify @state.toObject() logScreenLines: (start, end) -> @displayBuffer.logLines(start, end) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 441676bc9..8e076d526 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -1095,8 +1095,8 @@ class Editor extends View @clearRenderedLines() @removeAllCursorAndSelectionViews() - editSessionScrollTop = @activeEditSession.scrollTop ? 0 - editSessionScrollLeft = @activeEditSession.scrollLeft ? 0 + editSessionScrollTop = @activeEditSession.getScrollTop() ? 0 + editSessionScrollLeft = @activeEditSession.getScrollLeft() ? 0 @updateLayerDimensions() @scrollTop(editSessionScrollTop) @scrollLeft(editSessionScrollLeft)