Fix specs due to scrollTop/Left becoming methods on EditSession

This commit is contained in:
Kevin Sawicki & Nathan Sobo
2013-06-26 14:06:45 -06:00
committed by Nathan Sobo
parent f3f9c2c921
commit f4300b8cab
4 changed files with 13 additions and 11 deletions

View File

@@ -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', ->

View File

@@ -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

View File

@@ -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)

View File

@@ -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)