mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Autocomplete uses attach/detach
This commit is contained in:
@@ -49,12 +49,13 @@ class Autocomplete extends View
|
||||
cancel: ->
|
||||
@editor.getSelection().insertText @originalSelectedText
|
||||
@editor.setSelectionBufferRange(@originalSelectionBufferRange)
|
||||
@remove()
|
||||
@detach()
|
||||
|
||||
toggle: ->
|
||||
if @parent()[0] then @remove() else @show()
|
||||
if @parent()[0] then @detach() else @attach()
|
||||
|
||||
show: ->
|
||||
attach: ->
|
||||
@editor.addClass('autocomplete')
|
||||
@originalSelectedText = @editor.getSelectedText()
|
||||
@originalSelectionBufferRange = @editor.getSelection().getBufferRange()
|
||||
@buildMatchList()
|
||||
@@ -66,6 +67,10 @@ class Autocomplete extends View
|
||||
$(document.body).append(this)
|
||||
@focus()
|
||||
|
||||
detach: ->
|
||||
@editor.removeClass('autocomplete')
|
||||
super
|
||||
|
||||
previousMatch: ->
|
||||
previousIndex = @currentMatchIndex - 1
|
||||
previousIndex = @matches.length - 1 if previousIndex < 0
|
||||
@@ -90,7 +95,7 @@ class Autocomplete extends View
|
||||
|
||||
select: ->
|
||||
@editor.getSelection().clearSelection()
|
||||
@remove()
|
||||
@detach()
|
||||
@editor.focus()
|
||||
|
||||
buildWordList: () ->
|
||||
|
||||
Reference in New Issue
Block a user