From f0c36ada898df7f4c243ac60f6bb6070afc60053 Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Fri, 20 Apr 2012 15:14:52 -0600 Subject: [PATCH] Don't activate autocomplete on its own mini editor --- spec/app/autocomplete-spec.coffee | 8 ++++++-- src/app/autocomplete.coffee | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) 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'