mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Allow autocomplete package to be deactivated
This commit is contained in:
@@ -2,8 +2,15 @@ AutocompleteView = require './autocomplete-view'
|
||||
|
||||
module.exports =
|
||||
autoCompleteViews: []
|
||||
editorSubscription: null
|
||||
|
||||
activate: ->
|
||||
rootView.eachEditor (editor) =>
|
||||
@editorSubscription = rootView.eachEditor (editor) =>
|
||||
if editor.attached and not editor.mini
|
||||
@autoCompleteViews.push new AutocompleteView(editor)
|
||||
|
||||
deactivate: ->
|
||||
@editorSubscription?.off()
|
||||
@editorSubscription = null
|
||||
@autoCompleteViews.forEach (autoCompleteView) -> autoCompleteView.remove()
|
||||
@autoCompleteViews = []
|
||||
|
||||
@@ -33,6 +33,17 @@ describe "Autocomplete", ->
|
||||
rightEditor.trigger 'autocomplete:attach'
|
||||
expect(rightEditor.find('.autocomplete')).toExist()
|
||||
|
||||
describe "@deactivate()", ->
|
||||
it "removes all autocomplete views and doesn't create new ones when new editors are opened", ->
|
||||
atom.activatePackage('autocomplete')
|
||||
rootView.getActiveView().trigger "autocomplete:attach"
|
||||
expect(rootView.getActiveView().find('.autocomplete')).toExist()
|
||||
atom.deactivatePackage('autocomplete')
|
||||
expect(rootView.getActiveView().find('.autocomplete')).not.toExist()
|
||||
rootView.getActiveView().splitRight()
|
||||
rootView.getActiveView().trigger "autocomplete:attach"
|
||||
expect(rootView.getActiveView().find('.autocomplete')).not.toExist()
|
||||
|
||||
describe "AutocompleteView", ->
|
||||
autocomplete = null
|
||||
editor = null
|
||||
|
||||
Reference in New Issue
Block a user