Don't adjust match index when no matches exist

This commit is contained in:
Kevin Sawicki
2012-09-20 10:10:54 -07:00
parent 8393af2cd6
commit c42c824f0a

View File

@@ -135,11 +135,13 @@ class Autocomplete extends View
@css(left: left, top: potentialTop, bottom: 'inherit')
selectPreviousMatch: ->
return if @filteredMatches.length is 0
previousIndex = @currentMatchIndex - 1
previousIndex = @filteredMatches.length - 1 if previousIndex < 0
@selectMatchAtIndex(previousIndex)
selectNextMatch: ->
return if @filteredMatches.length is 0
nextIndex = (@currentMatchIndex + 1) % @filteredMatches.length
@selectMatchAtIndex(nextIndex)