mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Add move-down event to Autocomplete
This commit is contained in:
@@ -20,6 +20,7 @@ class Autocomplete extends View
|
||||
initialize: (@editor) ->
|
||||
requireStylesheet 'autocomplete.css'
|
||||
@on 'autocomplete:toggle', => @toggle()
|
||||
@on 'move-up', => @previousMatch()
|
||||
@on 'move-down', => @nextMatch()
|
||||
@editor.on 'buffer-path-change', => @setCurrentBuffer(@editor.buffer)
|
||||
|
||||
@@ -45,6 +46,11 @@ class Autocomplete extends View
|
||||
@css {left: left, top: top + @editor.lineHeight}
|
||||
$(document.body).append(this)
|
||||
|
||||
previousMatch: ->
|
||||
previousIndex = @currentMatchIndex - 1
|
||||
previousIndex = @matches.length - 1 if previousIndex < 0
|
||||
@selectMatch(previousIndex)
|
||||
|
||||
nextMatch: ->
|
||||
nextIndex = (@currentMatchIndex + 1) % @matches.length
|
||||
@selectMatch(nextIndex)
|
||||
|
||||
Reference in New Issue
Block a user