Don't activate autocomplete on its own mini editor

This commit is contained in:
Corey Johnson & Nathan Sobo 2012-04-20 15:14:52 -06:00
parent 41a5f217a5
commit f0c36ada89
2 changed files with 8 additions and 3 deletions

View File

@ -18,14 +18,16 @@ describe "Autocomplete", ->
afterEach ->
autocomplete.remove()
describe '@activate(rootView)', ->
it 'activates autocomplete on all existing and future editors', ->
describe "@activate(rootView)", ->
it "activates autocomplete on all existing and future editors (but not on autocomplete's own mini editor)", ->
rootView = new RootView(pathToOpen: require.resolve('fixtures/sample.js'))
rootView.simulateDomAttachment()
Autocomplete.activate(rootView)
leftEditor = rootView.activeEditor()
rightEditor = rootView.activeEditor().splitRight()
spyOn(Autocomplete.prototype, 'initialize')
leftEditor.trigger 'autocomplete:attach'
expect(leftEditor.find('.autocomplete')).toExist()
expect(rightEditor.find('.autocomplete')).not.toExist()
@ -35,6 +37,8 @@ describe "Autocomplete", ->
expect(leftEditor.find('.autocomplete')).not.toExist()
expect(rightEditor.find('.autocomplete')).toExist()
expect(Autocomplete.prototype.initialize).not.toHaveBeenCalled()
describe 'autocomplete:attach event', ->
it "shows autocomplete view and focuses its mini-editor", ->
expect(editor.find('.autocomplete')).not.toExist()

View File

@ -26,7 +26,8 @@ class Autocomplete extends View
@activate: (rootView) ->
new Autocomplete(editor) for editor in rootView.editors()
rootView.on 'editor-open', (e, editor) -> new Autocomplete(editor)
rootView.on 'editor-open', (e, editor) ->
new Autocomplete(editor) unless editor.is('.autocomplete .mini')
initialize: (@editor) ->
requireStylesheet 'autocomplete.css'