mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Bind meta-< to scroll to cursor location
This commit is contained in:
@@ -2552,3 +2552,14 @@ describe "Editor", ->
|
||||
|
||||
runs ->
|
||||
expect(editor.renderedLines.find('.line').text()).toBe 'hidden changes'
|
||||
|
||||
describe "editor:scroll-to-cursor", ->
|
||||
it "scrolls to and centers the editor on the cursor's position", ->
|
||||
editor.attachToDom(heightInLines: 3)
|
||||
editor.setCursorBufferPosition([1, 2])
|
||||
editor.scrollToBottom()
|
||||
expect(editor.getFirstVisibleScreenRow()).not.toBe 0
|
||||
expect(editor.getLastVisibleScreenRow()).not.toBe 2
|
||||
editor.trigger('editor:scroll-to-cursor')
|
||||
expect(editor.getFirstVisibleScreenRow()).toBe 0
|
||||
expect(editor.getLastVisibleScreenRow()).toBe 2
|
||||
|
||||
@@ -164,6 +164,7 @@ class Editor extends View
|
||||
'editor:toggle-indent-guide': => config.set('editor.showIndentGuide', !config.get('editor.showIndentGuide'))
|
||||
'editor:save-debug-snapshot': @saveDebugSnapshot
|
||||
'editor:toggle-line-numbers': => config.set('editor.showLineNumbers', !config.get('editor.showLineNumbers'))
|
||||
'editor:scroll-to-cursor': @scrollToCursorPosition
|
||||
|
||||
documentation = {}
|
||||
for name, method of editorBindings
|
||||
@@ -523,6 +524,9 @@ class Editor extends View
|
||||
scrollToBottom: ->
|
||||
@scrollBottom(@screenLineCount() * @lineHeight)
|
||||
|
||||
scrollToCursorPosition: ->
|
||||
@scrollToBufferPosition(@getCursorBufferPosition(), center: true)
|
||||
|
||||
scrollToBufferPosition: (bufferPosition, options) ->
|
||||
@scrollToPixelPosition(@pixelPositionForBufferPosition(bufferPosition), options)
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
'ctrl-meta-down': 'editor:move-line-down'
|
||||
'meta-D': 'editor:duplicate-line'
|
||||
'ctrl-J': 'editor:join-line'
|
||||
'meta-<': 'editor:scroll-to-cursor'
|
||||
|
||||
'.editor.mini':
|
||||
'enter': 'core:confirm',
|
||||
|
||||
Reference in New Issue
Block a user