mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-21 07:58:04 +03:00
Add Project::onDidCreateBuffer
This commit is contained in:
parent
ed4acb02d8
commit
4070e5fb25
@ -58,7 +58,7 @@ describe "Project", ->
|
|||||||
beforeEach ->
|
beforeEach ->
|
||||||
absolutePath = require.resolve('./fixtures/dir/a')
|
absolutePath = require.resolve('./fixtures/dir/a')
|
||||||
newBufferHandler = jasmine.createSpy('newBufferHandler')
|
newBufferHandler = jasmine.createSpy('newBufferHandler')
|
||||||
atom.project.on 'buffer-created', newBufferHandler
|
atom.project.onDidCreateBuffer newBufferHandler
|
||||||
|
|
||||||
describe "when given an absolute path that isn't currently open", ->
|
describe "when given an absolute path that isn't currently open", ->
|
||||||
it "returns a new edit session for the given path and emits 'buffer-created'", ->
|
it "returns a new edit session for the given path and emits 'buffer-created'", ->
|
||||||
|
@ -67,10 +67,21 @@ class Project extends Model
|
|||||||
onDidChangePath: (callback) ->
|
onDidChangePath: (callback) ->
|
||||||
@emitter.on 'did-change-path', callback
|
@emitter.on 'did-change-path', callback
|
||||||
|
|
||||||
|
|
||||||
|
# Extended: Invoke the given callback when a new buffer has been created. For
|
||||||
|
# example, when {::open} is called, this is fired.
|
||||||
|
#
|
||||||
|
# * `callback` {Function}
|
||||||
|
# * `buffer` {TextBuffer} the new buffer
|
||||||
|
onDidCreateBuffer: (callback) ->
|
||||||
|
@emitter.on 'did-create-buffer', callback
|
||||||
|
|
||||||
on: (eventName) ->
|
on: (eventName) ->
|
||||||
switch eventName
|
switch eventName
|
||||||
when 'path-changed'
|
when 'path-changed'
|
||||||
deprecate 'Use Project::onDidChangePath instead'
|
deprecate 'Use Project::onDidChangePath instead'
|
||||||
|
when 'buffer-created'
|
||||||
|
deprecate 'Use Project::onDidCreateBuffer instead'
|
||||||
else
|
else
|
||||||
deprecate 'Project::on is deprecated. Use event subscription methods instead.'
|
deprecate 'Project::on is deprecated. Use event subscription methods instead.'
|
||||||
EmitterMixin::on.apply(this, arguments)
|
EmitterMixin::on.apply(this, arguments)
|
||||||
@ -245,6 +256,7 @@ class Project extends Model
|
|||||||
@buffers.splice(index, 0, buffer)
|
@buffers.splice(index, 0, buffer)
|
||||||
buffer.onDidDestroy => @removeBuffer(buffer)
|
buffer.onDidDestroy => @removeBuffer(buffer)
|
||||||
@emit 'buffer-created', buffer
|
@emit 'buffer-created', buffer
|
||||||
|
@emitter.emit 'did-create-buffer', buffer
|
||||||
buffer
|
buffer
|
||||||
|
|
||||||
# Removes a {TextBuffer} association from the project.
|
# Removes a {TextBuffer} association from the project.
|
||||||
|
Loading…
Reference in New Issue
Block a user