Return top and left values of 0 when not visible

This commit is contained in:
Kevin Sawicki 2013-04-08 13:03:19 -07:00
parent 8993258e74
commit c7175c7e5f
2 changed files with 20 additions and 1 deletions

View File

@ -2037,6 +2037,25 @@ describe "Editor", ->
runs ->
expect(editor.getText()).toBe(originalPathText)
describe ".pixelPositionForBufferPosition(position)", ->
describe "when the editor is detached", ->
it "returns top and left values of 0", ->
expect(editor.isOnDom()).toBeFalsy()
expect(editor.pixelPositionForBufferPosition([2,7])).toEqual top: 0, left: 0
describe "when the editor is invisible", ->
it "returns top and left values of 0", ->
editor.attachToDom()
editor.hide()
expect(editor.isVisible()).toBeFalsy()
expect(editor.pixelPositionForBufferPosition([2,7])).toEqual top: 0, left: 0
describe "when the editor is attached and visible", ->
it "returns the top and left pixel positions", ->
editor.attachToDom()
expect(editor.pixelPositionForBufferPosition([2,7])).toEqual top: 40, left: 70
describe "when clicking in the gutter", ->
beforeEach ->
editor.attachToDom()

View File

@ -1086,7 +1086,7 @@ class Editor extends View
@pixelPositionForScreenPosition(@screenPositionForBufferPosition(position))
pixelPositionForScreenPosition: (position) ->
return { top: 0, left: 0 } unless @isOnDom()
return { top: 0, left: 0 } unless @isOnDom() and @isVisible()
{row, column} = Point.fromObject(position)
actualRow = Math.floor(row)