mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Deprecate Dock::getActiveTextEditor()
This commit is contained in:
@@ -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)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user