mirror of
https://github.com/atom/atom.git
synced 2026-01-25 14:59:03 -05:00
wip
This commit is contained in:
@@ -483,7 +483,7 @@ fdescribe "TextEditorPresenter", ->
|
||||
|
||||
describe ".hiddenInput", ->
|
||||
describe ".top/.left", ->
|
||||
fffit "is positioned over the last cursor it is in view and the editor is focused", ->
|
||||
it "is positioned over the last cursor it is in view and the editor is focused", ->
|
||||
editor.setCursorBufferPosition([3, 6])
|
||||
presenter = buildPresenter(focused: false, explicitHeight: 50, contentFrameWidth: 300, horizontalScrollbarHeight: 0, verticalScrollbarWidth: 0)
|
||||
expectValues presenter.getState().hiddenInput, {top: 0, left: 0}
|
||||
|
||||
@@ -380,6 +380,11 @@ class DisplayBuffer extends Model
|
||||
left -= @getHorizontalScrollMargin()
|
||||
right += @getHorizontalScrollMargin()
|
||||
|
||||
top = Math.max(0, Math.min(@getLineCount() - 1, top))
|
||||
bottom = Math.max(0, Math.min(@getLineCount() - 1, bottom))
|
||||
left = Math.max(0, left)
|
||||
right = Math.max(0, right)
|
||||
|
||||
screenRange = new Range(new Point(top, left), new Point(bottom, right))
|
||||
|
||||
scrollEvent = {screenRange, options}
|
||||
|
||||
@@ -1477,39 +1477,43 @@ class TextEditorPresenter
|
||||
|
||||
{screenRange, options} = @pendingScrollLogicalPosition
|
||||
|
||||
console.log screenRange.start.toString()
|
||||
console.log screenRange.end.toString()
|
||||
# console.log screenRange.start.toString()
|
||||
{top, left} = @pixelRectForScreenRange(new Range(screenRange.start, screenRange.start))
|
||||
{top: endTop, left: endLeft, height: endHeight} = @pixelRectForScreenRange(new Range(screenRange.end, screenRange.end))
|
||||
bottom = endTop + endHeight
|
||||
right = endLeft
|
||||
|
||||
left += @scrollLeft
|
||||
right += @scrollLeft
|
||||
top += @scrollTop
|
||||
bottom += @scrollTop
|
||||
|
||||
if global.enableLogs
|
||||
console.log "====== presenter ======"
|
||||
console.log "Client Height: #{@getClientHeight()}"
|
||||
console.log "#{desiredScrollTop}/#{desiredScrollBottom}"
|
||||
console.log "#{top}/#{bottom}"
|
||||
console.log "#{@getScrollTop()}/#{@getScrollBottom()}"
|
||||
console.log "======================="
|
||||
|
||||
if options?.reversed ? true
|
||||
if desiredScrollBottom > @getScrollBottom()
|
||||
@setScrollBottom(desiredScrollBottom)
|
||||
if desiredScrollTop < @getScrollTop()
|
||||
@setScrollTop(desiredScrollTop)
|
||||
if bottom > @getScrollBottom()
|
||||
@setScrollBottom(bottom)
|
||||
if top < @getScrollTop()
|
||||
@setScrollTop(top)
|
||||
|
||||
if desiredScrollRight > @getScrollRight()
|
||||
@setScrollRight(desiredScrollRight)
|
||||
if desiredScrollLeft < @getScrollLeft()
|
||||
@setScrollLeft(desiredScrollLeft)
|
||||
if right > @getScrollRight()
|
||||
@setScrollRight(right)
|
||||
if left < @getScrollLeft()
|
||||
@setScrollLeft(left)
|
||||
else
|
||||
if desiredScrollTop < @getScrollTop()
|
||||
@setScrollTop(desiredScrollTop)
|
||||
if desiredScrollBottom > @getScrollBottom()
|
||||
@setScrollBottom(desiredScrollBottom)
|
||||
if top < @getScrollTop()
|
||||
@setScrollTop(top)
|
||||
if bottom > @getScrollBottom()
|
||||
@setScrollBottom(bottom)
|
||||
|
||||
if desiredScrollLeft < @getScrollLeft()
|
||||
@setScrollLeft(desiredScrollLeft)
|
||||
if desiredScrollRight > @getScrollRight()
|
||||
@setScrollRight(desiredScrollRight)
|
||||
if left < @getScrollLeft()
|
||||
@setScrollLeft(left)
|
||||
if right > @getScrollRight()
|
||||
@setScrollRight(right)
|
||||
|
||||
@pendingScrollLogicalPosition = null
|
||||
|
||||
Reference in New Issue
Block a user