From 7270758a9e0597486df9d3eb93ba67d619ba773c Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 25 Jul 2012 13:26:57 -0600 Subject: [PATCH] Focus the active editor after executing a previewed operation --- spec/extensions/command-panel-spec.coffee | 8 ++++++-- src/extensions/command-panel/preview-list.coffee | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/extensions/command-panel-spec.coffee b/spec/extensions/command-panel-spec.coffee index 786c0260f..9fe0e52f2 100644 --- a/spec/extensions/command-panel-spec.coffee +++ b/spec/extensions/command-panel-spec.coffee @@ -324,7 +324,8 @@ describe "CommandPanel", -> console.log previewList.find('li:first').position().top describe "when command-panel:execute is triggered on the preview list", -> - it "opens a new editor with the operation's buffer and selects the search result", -> + it "opens the operation's buffer, selects the search result, and focuses the active editor", -> + spyOn(rootView, 'focus') executeHandler = jasmine.createSpy('executeHandler') commandPanel.on 'command-panel:execute', executeHandler @@ -336,11 +337,13 @@ describe "CommandPanel", -> editSession = rootView.getActiveEditSession() expect(editSession.buffer.getPath()).toBe project.resolve(operation.getPath()) expect(editSession.getSelectedBufferRange()).toEqual operation.getBufferRange() + expect(rootView.focus).toHaveBeenCalled() expect(executeHandler).not.toHaveBeenCalled() describe "when an operation in the preview list is clicked", -> - it "opens a new editor with the operation's buffer and selects the search result", -> + it "opens the operation's buffer, selects the search result, and focuses the active editor", -> + spyOn(rootView, 'focus') operation = previewList.getOperations()[4] previewList.find('li:eq(4) span').mousedown() @@ -349,3 +352,4 @@ describe "CommandPanel", -> editSession = rootView.getActiveEditSession() expect(editSession.buffer.getPath()).toBe project.resolve(operation.getPath()) expect(editSession.getSelectedBufferRange()).toEqual operation.getBufferRange() + expect(rootView.focus).toHaveBeenCalled() diff --git a/src/extensions/command-panel/preview-list.coffee b/src/extensions/command-panel/preview-list.coffee index 31d338f3f..57828d7d3 100644 --- a/src/extensions/command-panel/preview-list.coffee +++ b/src/extensions/command-panel/preview-list.coffee @@ -59,6 +59,7 @@ class PreviewList extends View operation = @getSelectedOperation() editSession = @rootView.open(operation.getPath()) operation.execute(editSession) + @rootView.focus() false getOperations: ->