diff --git a/spec/app/autocomplete-spec.coffee b/spec/app/autocomplete-spec.coffee index ec281470b..b52aa4839 100644 --- a/spec/app/autocomplete-spec.coffee +++ b/spec/app/autocomplete-spec.coffee @@ -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() diff --git a/src/app/autocomplete.coffee b/src/app/autocomplete.coffee index 4866cc2f2..81dc6b08d 100644 --- a/src/app/autocomplete.coffee +++ b/src/app/autocomplete.coffee @@ -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'