diff --git a/spec/workspace-view-spec.coffee b/spec/workspace-view-spec.coffee index f48dfc3d2..45c88d4af 100644 --- a/spec/workspace-view-spec.coffee +++ b/spec/workspace-view-spec.coffee @@ -2,6 +2,7 @@ Q = require 'q' path = require 'path' temp = require 'temp' +EditorView = require '../src/editor-view' PaneView = require '../src/pane-view' Workspace = require '../src/workspace' @@ -222,6 +223,14 @@ describe "WorkspaceView", -> expect(count).toBe 1 expect(callbackEditor).toBe atom.workspaceView.getActiveView() + it "does not invoke the callback for mini editors", -> + editorViewCreatedHandler = jasmine.createSpy('editorViewCreatedHandler') + atom.workspaceView.eachEditorView(editorViewCreatedHandler) + editorViewCreatedHandler.reset() + miniEditor = new EditorView(mini: true) + atom.workspaceView.append(miniEditor) + expect(editorViewCreatedHandler).not.toHaveBeenCalled() + it "returns a subscription that can be disabled", -> count = 0 callback = (editor) -> count++ diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index efbf25b2d..b11ccc8cf 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -320,15 +320,17 @@ class WorkspaceView extends View @panes.getPaneViews() # Public: Register a function to be called for every current and future - # editor view in the workspace. + # editor view in the workspace (only includes {EditorView}s that are pane + # items). # # callback - A {Function} with an {EditorView} as its only argument. # # Returns a subscription object with an `.off` method that you can call to # unregister the callback. eachEditorView: (callback) -> - callback(editor) for editor in @getEditorViews() - attachedCallback = (e, editor) -> callback(editor) + callback(editorView) for editorView in @getEditorViews() + attachedCallback = (e, editorView) -> + callback(editorView) unless editorView.mini @on('editor:attached', attachedCallback) off: => @off('editor:attached', attachedCallback)