diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 9fe7e94e0..c7d21989e 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -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() diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 5eefef7bb..81c6eb83f 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -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)