diff --git a/spec/atom/root-view-spec.coffee b/spec/atom/root-view-spec.coffee index e98bfabc2..c10ecf959 100644 --- a/spec/atom/root-view-spec.coffee +++ b/spec/atom/root-view-spec.coffee @@ -47,7 +47,6 @@ describe "RootView", -> expect(rootView).not.toMatchSelector(':focus') expect(rootView.activeEditor().isFocused).toBeTruthy() - describe "split editor panes", -> editor1 = null @@ -328,6 +327,13 @@ describe "RootView", -> expect(editor1.buffer.url).not.toBe expectedUrl expect(editor2.buffer.url).toBe expectedUrl + describe "text search", -> + describe "when find event is triggered", -> + it "pre-populates command panel's editor with /", -> + rootView.trigger "find-in-file" + expect(rootView.commandPanel.parent).not.toBeEmpty() + expect(rootView.commandPanel.editor.getText()).toBe "/" + describe "keymap wiring", -> commandHandler = null beforeEach -> diff --git a/src/atom/command-panel.coffee b/src/atom/command-panel.coffee index 611ecabd3..9f8564421 100644 --- a/src/atom/command-panel.coffee +++ b/src/atom/command-panel.coffee @@ -24,15 +24,18 @@ class CommandPanel extends View @commandInterpreter = new CommandInterpreter() toggle: -> - if @parent().length - @detach() - @rootView.activeEditor().focus() - else - @rootView.append(this) - @prompt.css 'font', @editor.css('font') - @editor.focus() - @editor.buffer.setText('') + if @parent().length then @hide() else @show() + + show: -> + @rootView.append(this) + @prompt.css 'font', @editor.css('font') + @editor.focus() + @editor.buffer.setText('') + + hide: -> + @detach() + @rootView.activeEditor().focus() execute: -> @commandInterpreter.eval(@rootView.activeEditor(), @editor.getText()) - @toggle() \ No newline at end of file + @hide() \ No newline at end of file diff --git a/src/atom/root-view.coffee b/src/atom/root-view.coffee index 7a57e14bf..fdc054ff6 100644 --- a/src/atom/root-view.coffee +++ b/src/atom/root-view.coffee @@ -28,9 +28,13 @@ class RootView extends View 'meta-t': 'toggle-file-finder' 'meta-:': 'command-panel:toggle' 'alt-meta-i': 'show-console' + 'meta-f': 'find-in-file' @on 'toggle-file-finder', => @toggleFileFinder() @on 'show-console', -> window.showConsole() + @on 'find-in-file', => + @commandPanel.show() + @commandPanel.editor.setText("/") @one 'attach', => @focus() @on 'focus', (e) =>