mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Handle 'editor:scroll-to-cursor' command
Add Editor::scrollToCursorPosition in the model layer
This commit is contained in:
@@ -3028,3 +3028,17 @@ describe "Editor", ->
|
||||
editor.setSoftTabs(false)
|
||||
editor.normalizeTabsInBufferRange([[0, 0], [Infinity, Infinity]])
|
||||
expect(editor.getText()).toBe ' '
|
||||
|
||||
describe ".scrollToCursorPosition()", ->
|
||||
it "scrolls the last cursor into view", ->
|
||||
editor.setCursorScreenPosition([8, 8])
|
||||
editor.setLineHeight(10)
|
||||
editor.setDefaultCharWidth(10)
|
||||
editor.setHeight(50)
|
||||
editor.setWidth(50)
|
||||
expect(editor.getScrollTop()).toBe 0
|
||||
expect(editor.getScrollLeft()).toBe 0
|
||||
|
||||
editor.scrollToCursorPosition()
|
||||
expect(editor.getScrollBottom()).toBe (9 + editor.getVerticalScrollMargin()) * 10
|
||||
expect(editor.getScrollRight()).toBe (9 + editor.getHorizontalScrollMargin()) * 10
|
||||
|
||||
@@ -215,9 +215,9 @@ EditorComponent = React.createClass
|
||||
'editor:join-lines': => editor.joinLines()
|
||||
'editor:toggle-indent-guide': => atom.config.toggle('editor.showIndentGuide')
|
||||
'editor:toggle-line-numbers': => atom.config.toggle('editor.showLineNumbers')
|
||||
'editor:scroll-to-cursor': => editor.scrollToCursorPosition()
|
||||
# 'core:page-down': => @pageDown()
|
||||
# 'core:page-up': => @pageUp()
|
||||
# 'editor:scroll-to-cursor': => @scrollToCursorPosition()
|
||||
|
||||
addCommandListeners: (listenersByCommandName) ->
|
||||
{parentView} = @props
|
||||
|
||||
@@ -1453,6 +1453,9 @@ class Editor extends Model
|
||||
moveCursorToNextWordBoundary: ->
|
||||
@moveCursors (cursor) -> cursor.moveToNextWordBoundary()
|
||||
|
||||
scrollToCursorPosition: ->
|
||||
@getCursor().autoscroll()
|
||||
|
||||
moveCursors: (fn) ->
|
||||
@movingCursors = true
|
||||
@batchUpdates =>
|
||||
|
||||
Reference in New Issue
Block a user