mirror of
https://github.com/atom/atom.git
synced 2026-01-24 06:18:03 -05:00
autoscroll to results in command panel preview list
This commit is contained in:
@@ -935,6 +935,9 @@ class Editor extends View
|
||||
getLastVisibleScreenRow: ->
|
||||
Math.max(0, Math.ceil((@scrollTop() + @scrollView.height()) / @lineHeight) - 1)
|
||||
|
||||
isScreenRowVisible: (row) ->
|
||||
@getFirstVisibleScreenRow() <= row <= @getLastVisibleScreenRow()
|
||||
|
||||
handleScreenLinesChange: (change) ->
|
||||
@pendingChanges.push(change)
|
||||
@requestDisplayUpdate()
|
||||
|
||||
@@ -374,7 +374,7 @@ describe "CommandPanel", ->
|
||||
beforeEach ->
|
||||
previewList = commandPanel.previewList
|
||||
rootView.trigger 'command-panel:toggle'
|
||||
waitsForPromise -> commandPanel.execute('X x/a+/')
|
||||
waitsForPromise -> commandPanel.execute('X x/apply/')
|
||||
|
||||
describe "when move-down and move-up are triggered on the preview list", ->
|
||||
it "selects the next/previous operation (if there is one), and scrolls the list if needed", ->
|
||||
@@ -408,7 +408,10 @@ describe "CommandPanel", ->
|
||||
_.times previewList.getOperations().length, -> previewList.trigger 'core:move-up'
|
||||
|
||||
describe "when core:confirm is triggered on the preview list", ->
|
||||
it "opens the operation's buffer, selects the search result, and focuses the active editor", ->
|
||||
it "opens the operation's buffer, selects and scrolls to the search result, and focuses the active editor", ->
|
||||
rootView.height(200)
|
||||
rootView.attachToDom()
|
||||
|
||||
spyOn(rootView, 'focus')
|
||||
executeHandler = jasmine.createSpy('executeHandler')
|
||||
commandPanel.on 'core:confirm', executeHandler
|
||||
@@ -421,6 +424,9 @@ describe "CommandPanel", ->
|
||||
editSession = rootView.getActiveEditSession()
|
||||
expect(editSession.buffer.getPath()).toBe project.resolve(operation.getPath())
|
||||
expect(editSession.getSelectedBufferRange()).toEqual operation.getBufferRange()
|
||||
expect(editSession.getSelectedBufferRange()).toEqual operation.getBufferRange()
|
||||
console.log editor.getCursorScreenRow(), editor.getFirstVisibleScreenRow(), editor.getLastVisibleScreenRow()
|
||||
expect(editor.isScreenRowVisible(editor.getCursorScreenRow())).toBeTruthy()
|
||||
expect(rootView.focus).toHaveBeenCalled()
|
||||
|
||||
expect(executeHandler).not.toHaveBeenCalled()
|
||||
|
||||
@@ -61,7 +61,7 @@ class PreviewList extends ScrollView
|
||||
operation = @getSelectedOperation()
|
||||
editSession = @rootView.open(operation.getPath())
|
||||
bufferRange = operation.execute(editSession)
|
||||
editSession.setSelectedBufferRange(bufferRange) if bufferRange
|
||||
editSession.setSelectedBufferRange(bufferRange, autoscroll: true) if bufferRange
|
||||
@rootView.focus()
|
||||
false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user