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:
Kevin Sawicki
2013-01-25 08:51:16 -08:00
parent 789c0a3715
commit 63b9a4b179
2 changed files with 4 additions and 23 deletions

View File

@@ -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", ->

View File

@@ -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)