mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Delegate getFirst/LastVisibleScreenRow from model to component
This commit is contained in:
committed by
Antonio Scandurra
parent
19f5535d68
commit
493b735740
@@ -2483,6 +2483,17 @@ describe('TextEditorComponent', () => {
|
||||
expect(component.getScrollContainerWidth()).toBe(100)
|
||||
expect(Grim.deprecate.callCount).toBe(2)
|
||||
})
|
||||
|
||||
it('delegates getFirstVisibleScreenRow, getLastVisibleScreenRow, and getVisibleRowRange to the component', async () => {
|
||||
const {component, element, editor} = buildComponent({rowsPerTile: 3, autoHeight: false})
|
||||
element.style.height = 4 * component.measurements.lineHeight + 'px'
|
||||
await component.getNextUpdatePromise()
|
||||
await setScrollTop(component, 5 * component.getLineHeight())
|
||||
|
||||
expect(editor.getFirstVisibleScreenRow()).toBe(component.getFirstVisibleRow())
|
||||
expect(editor.getLastVisibleScreenRow()).toBe(component.getLastVisibleRow())
|
||||
expect(editor.getVisibleRowRange()).toEqual([component.getFirstVisibleRow(), component.getLastVisibleRow()])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -3686,17 +3686,14 @@ class TextEditor extends Model
|
||||
|
||||
getFirstVisibleScreenRow: -> @firstVisibleScreenRow
|
||||
|
||||
getFirstVisibleScreenRow: ->
|
||||
@getElement().component.getFirstVisibleRow()
|
||||
|
||||
getLastVisibleScreenRow: ->
|
||||
if @height? and @lineHeightInPixels?
|
||||
Math.min(@firstVisibleScreenRow + Math.floor(@height / @lineHeightInPixels), @getScreenLineCount() - 1)
|
||||
else
|
||||
null
|
||||
@getElement().component.getLastVisibleRow()
|
||||
|
||||
getVisibleRowRange: ->
|
||||
if lastVisibleScreenRow = @getLastVisibleScreenRow()
|
||||
[@firstVisibleScreenRow, lastVisibleScreenRow]
|
||||
else
|
||||
null
|
||||
[@getFirstVisibleScreenRow(), @getLastVisibleScreenRow()]
|
||||
|
||||
setFirstVisibleScreenColumn: (@firstVisibleScreenColumn) ->
|
||||
getFirstVisibleScreenColumn: -> @firstVisibleScreenColumn
|
||||
|
||||
Reference in New Issue
Block a user