diff --git a/spec/dock-spec.js b/spec/dock-spec.js index f9b8a5326..e554094f2 100644 --- a/spec/dock-spec.js +++ b/spec/dock-spec.js @@ -1,5 +1,7 @@ /** @babel */ +const Grim = require('grim') + import {it, fit, ffit, fffit, beforeEach, afterEach} from './async-spec-helpers' describe('Dock', () => { @@ -329,4 +331,13 @@ describe('Dock', () => { expect(() => atom.workspace.getElement().handleDragStart(dragEvent)).not.toThrow() }) }) + + describe('::getActiveTextEditor()', () => { + it('is deprecated', () => { + spyOn(Grim, 'deprecate') + + atom.workspace.getLeftDock().getActiveTextEditor() + expect(Grim.deprecate.callCount).toBe(1) + }) + }) }) diff --git a/src/dock.js b/src/dock.js index cc6d0bcf2..f354f1b90 100644 --- a/src/dock.js +++ b/src/dock.js @@ -4,6 +4,7 @@ const _ = require('underscore-plus') const {CompositeDisposable} = require('event-kit') const PaneContainer = require('./pane-container') const TextEditor = require('./text-editor') +const Grim = require('grim') const MINIMUM_SIZE = 100 const DEFAULT_INITIAL_SIZE = 300 @@ -590,11 +591,13 @@ module.exports = class Dock { return this.paneContainer.getTextEditors() } - // Essential: Get the active item if it is a {TextEditor}. + // Deprecated: Get the active item if it is a {TextEditor}. // // Returns a {TextEditor} or `undefined` if the current active item is not a // {TextEditor}. getActiveTextEditor () { + Grim.deprecate('Text editors are not allowed in docks. Use atom.workspace.getActiveTextEditor() instead.') + const activeItem = this.getActivePaneItem() if (activeItem instanceof TextEditor) { return activeItem } }