Issue #29 Command and file autocomplete
This commit is contained in:
parent
dfa44b5fa2
commit
7e1e03284a
4 changed files with 169 additions and 0 deletions
|
|
@ -1,4 +1,6 @@
|
|||
{ViewModel, Input} = require './view-model'
|
||||
AutoComplete = require './autocomplete'
|
||||
Ex = require './ex'
|
||||
|
||||
module.exports =
|
||||
class ExViewModel extends ViewModel
|
||||
|
|
@ -6,15 +8,31 @@ class ExViewModel extends ViewModel
|
|||
super(@exCommand, class: 'command')
|
||||
@historyIndex = -1
|
||||
|
||||
@view.editorElement.addEventListener('keydown', @tabAutocomplete)
|
||||
atom.commands.add(@view.editorElement, 'core:move-up', @increaseHistoryEx)
|
||||
atom.commands.add(@view.editorElement, 'core:move-down', @decreaseHistoryEx)
|
||||
|
||||
@autoComplete = new AutoComplete(Ex.getCommands())
|
||||
|
||||
restoreHistory: (index) ->
|
||||
@view.editorElement.getModel().setText(@history(index).value)
|
||||
|
||||
history: (index) ->
|
||||
@exState.getExHistoryItem(index)
|
||||
|
||||
tabAutocomplete: (event) =>
|
||||
if event.keyCode == 9
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
|
||||
completed = @autoComplete.getAutocomplete(@view.editorElement.getModel().getText())
|
||||
if completed
|
||||
@view.editorElement.getModel().setText(completed)
|
||||
|
||||
return false
|
||||
else
|
||||
@autoComplete.resetCompletion()
|
||||
|
||||
increaseHistoryEx: =>
|
||||
if @history(@historyIndex + 1)?
|
||||
@historyIndex += 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue