Listen for clicks outside of the render lines on the underlayer

This commit is contained in:
probablycorey 2013-04-30 15:03:44 -07:00
parent 7609b08e86
commit cb2d24baca
3 changed files with 11 additions and 18 deletions

View File

@ -1214,7 +1214,7 @@ describe "Editor", ->
describe "when scrolling more than the editors height", ->
it "removes lines that are offscreen and not in range of the overdraw and builds lines that become visible", ->
editor.scrollTop(editor.scrollView.prop('scrollHeight') - editor.scrollView.height())
editor.scrollTop(editor.layerHeight - editor.scrollView.height())
expect(editor.renderedLines.find('.line').length).toBe 8
expect(editor.renderedLines.find('.line:first').text()).toBe buffer.lineForRow(5)
expect(editor.renderedLines.find('.line:last').text()).toBe buffer.lineForRow(12)
@ -2131,16 +2131,13 @@ describe "Editor", ->
it "move the cursor to the end of the file", ->
expect(editor.getCursorScreenPosition()).toEqual [0,0]
event = $.Event("click")
event.offsetY = Infinity
event = mousedownEvent(editor: editor, point: [Infinity, 10])
editor.underlayer.trigger event
expect(editor.getCursorScreenPosition()).toEqual [12,2]
it "selects to the end of the files when shift is pressed", ->
expect(editor.getSelection().getScreenRange()).toEqual [[0,0], [0,0]]
event = $.Event("click")
event.offsetY = Infinity
event.shiftKey = true
event = mousedownEvent(editor: editor, point: [Infinity, 10], shiftKey: true)
editor.underlayer.trigger event
expect(editor.getSelection().getScreenRange()).toEqual [[0,0], [12,2]]

View File

@ -821,13 +821,9 @@ class Editor extends View
@isFocused = false
@removeClass 'is-focused'
@underlayer.on 'click', (e) =>
return unless e.target is @underlayer[0]
return unless e.offsetY > @overlayer.height()
if e.shiftKey
@selectToBottom()
else
@moveCursorToBottom()
@underlayer.on 'mousedown', (e) =>
@renderedLines.trigger(e)
false
@overlayer.on 'mousedown', (e) =>
@overlayer.hide()
@ -1275,14 +1271,14 @@ class Editor extends View
updateLayerDimensions: ->
height = @lineHeight * @getScreenLineCount()
unless @layerHeight == height
@underlayer.css('min-height', height)
@renderedLines.height(height)
@overlayer.height(height)
@layerHeight = height
@renderedLines.height(@layerHeight)
@overlayer.height(@layerHeight)
bottomPaddingInLines = if @mini then 0 else @bottomPaddingInLines
heightWithPadding = height + (@lineHeight * bottomPaddingInLines)
heightWithPadding = @layerHeight + (@lineHeight * bottomPaddingInLines)
@verticalScrollbarContent.height(heightWithPadding)
@underlayer.height(heightWithPadding)
@scrollBottom(height) if @scrollBottom() > height

View File

@ -125,7 +125,7 @@
.editor .underlayer {
z-index: 0;
position: absolute;
height: 100%;
min-height: 100%;
}
.editor .lines {