mirror of
https://github.com/atom/atom.git
synced 2026-02-13 16:14:59 -05:00
Kill wrap-around in command panel preview list
Jumping from top to bottom can be still done using meta-up and meta-down.
This commit is contained in:
@@ -405,28 +405,15 @@ describe "CommandPanel", ->
|
||||
previewList.trigger 'core:move-down'
|
||||
expect(previewList.scrollTop()).toBe 0
|
||||
|
||||
it "wraps around when the list is at the beginning or end", ->
|
||||
rootView.attachToDom()
|
||||
expect(previewList.find('li.operation:eq(0)')).toHaveClass 'selected'
|
||||
expect(previewList.getSelectedOperation()).toBe previewList.getOperations()[0]
|
||||
|
||||
previewList.trigger 'core:move-up'
|
||||
expect(previewList.find('li.operation:last')).toHaveClass 'selected'
|
||||
expect(previewList.getSelectedOperation()).toBe _.last(previewList.getOperations())
|
||||
|
||||
previewList.trigger 'core:move-down'
|
||||
expect(previewList.find('li.operation:eq(0)')).toHaveClass 'selected'
|
||||
expect(previewList.getSelectedOperation()).toBe previewList.getOperations()[0]
|
||||
|
||||
it "doesn't bubble up the event and the command panel text doesn't change", ->
|
||||
rootView.attachToDom()
|
||||
commandPanel.miniEditor.setText "command"
|
||||
previewList.focus()
|
||||
previewList.trigger 'core:move-up'
|
||||
expect(previewList.find('li.operation:last')).toHaveClass 'selected'
|
||||
expect(previewList.find('li.operation:eq(0)')).toHaveClass 'selected'
|
||||
expect(commandPanel.miniEditor.getText()).toBe 'command'
|
||||
previewList.trigger 'core:move-down'
|
||||
expect(previewList.find('li.operation:eq(0)')).toHaveClass 'selected'
|
||||
expect(previewList.find('li.operation:eq(1)')).toHaveClass 'selected'
|
||||
expect(commandPanel.miniEditor.getText()).toBe 'command'
|
||||
|
||||
describe "when move-to-top and move-to-bottom are triggered on the preview list", ->
|
||||
|
||||
@@ -56,16 +56,10 @@ class PreviewList extends ScrollView
|
||||
lineNumbers.width(maxWidth)
|
||||
|
||||
selectNextOperation: ->
|
||||
if @selectedOperationIndex is @operations.length - 1
|
||||
@setSelectedOperationIndex(0)
|
||||
else
|
||||
@setSelectedOperationIndex(@selectedOperationIndex + 1)
|
||||
@setSelectedOperationIndex(@selectedOperationIndex + 1)
|
||||
|
||||
selectPreviousOperation: ->
|
||||
if @selectedOperationIndex is 0
|
||||
@setSelectedOperationIndex(@operations.length - 1)
|
||||
else
|
||||
@setSelectedOperationIndex(@selectedOperationIndex - 1)
|
||||
@setSelectedOperationIndex(@selectedOperationIndex - 1)
|
||||
|
||||
setSelectedOperationIndex: (index, scrollToOperation=true) ->
|
||||
index = Math.max(0, index)
|
||||
|
||||
Reference in New Issue
Block a user