mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-05 22:04:34 +03:00
Fire edit-session-created event when deserializing
This event was previously not being fired when splitting panes since the constructor pushing the edit session directly to the project's array. Closes #684
This commit is contained in:
parent
7d58008ed3
commit
633306e6bf
@ -1,3 +1,4 @@
|
|||||||
|
* Fixed: Wrap in quotes/parens now works in split panes
|
||||||
* Improved: Autocomplete now includes CSS property names and values
|
* Improved: Autocomplete now includes CSS property names and values
|
||||||
* Improved: Settings GUI is now a pane item
|
* Improved: Settings GUI is now a pane item
|
||||||
* Added: Support package filtering in Settings GUI
|
* Added: Support package filtering in Settings GUI
|
||||||
|
@ -31,6 +31,22 @@ describe "Project", ->
|
|||||||
expect(project.getPath()).toBe '/tmp'
|
expect(project.getPath()).toBe '/tmp'
|
||||||
fsUtils.remove('/tmp/atom-test-save-sets-project-path')
|
fsUtils.remove('/tmp/atom-test-save-sets-project-path')
|
||||||
|
|
||||||
|
describe "when an edit session is deserialized", ->
|
||||||
|
it "emits an 'edit-session-created' event and stores the edit session", ->
|
||||||
|
handler = jasmine.createSpy('editSessionCreatedHandler')
|
||||||
|
project.on 'edit-session-created', handler
|
||||||
|
|
||||||
|
editSession1 = project.open("a")
|
||||||
|
expect(handler.callCount).toBe 1
|
||||||
|
expect(project.getEditSessions().length).toBe 1
|
||||||
|
expect(project.getEditSessions()[0]).toBe editSession1
|
||||||
|
|
||||||
|
editSession2 = deserialize(editSession1.serialize())
|
||||||
|
expect(handler.callCount).toBe 2
|
||||||
|
expect(project.getEditSessions().length).toBe 2
|
||||||
|
expect(project.getEditSessions()[0]).toBe editSession1
|
||||||
|
expect(project.getEditSessions()[1]).toBe editSession2
|
||||||
|
|
||||||
describe ".open(path)", ->
|
describe ".open(path)", ->
|
||||||
[fooOpener, barOpener, absolutePath, newBufferHandler, newEditSessionHandler] = []
|
[fooOpener, barOpener, absolutePath, newBufferHandler, newEditSessionHandler] = []
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
@ -36,13 +36,13 @@ class EditSession
|
|||||||
|
|
||||||
constructor: (optionsOrState) ->
|
constructor: (optionsOrState) ->
|
||||||
if optionsOrState instanceof telepath.Document
|
if optionsOrState instanceof telepath.Document
|
||||||
project.editSessions.push(this)
|
|
||||||
@state = optionsOrState
|
@state = optionsOrState
|
||||||
{tabLength, softTabs, @softWrap} = @state.toObject()
|
{tabLength, softTabs, @softWrap} = @state.toObject()
|
||||||
@buffer = deserialize(@state.get('buffer'))
|
@buffer = deserialize(@state.get('buffer'))
|
||||||
@setScrollTop(@state.get('scrollTop'))
|
@setScrollTop(@state.get('scrollTop'))
|
||||||
@setScrollLeft(@state.get('scrollLeft'))
|
@setScrollLeft(@state.get('scrollLeft'))
|
||||||
cursorScreenPosition = @state.getObject('cursorScreenPosition')
|
cursorScreenPosition = @state.getObject('cursorScreenPosition')
|
||||||
|
project.addEditSession(this)
|
||||||
else
|
else
|
||||||
{@buffer, tabLength, softTabs, @softWrap} = optionsOrState
|
{@buffer, tabLength, softTabs, @softWrap} = optionsOrState
|
||||||
@state = telepath.Document.create
|
@state = telepath.Document.create
|
||||||
|
@ -179,6 +179,10 @@ class Project
|
|||||||
getEditSessions: ->
|
getEditSessions: ->
|
||||||
new Array(@editSessions...)
|
new Array(@editSessions...)
|
||||||
|
|
||||||
|
addEditSession: (editSession) ->
|
||||||
|
@editSessions.push editSession
|
||||||
|
@trigger 'edit-session-created', editSession
|
||||||
|
|
||||||
### Public ###
|
### Public ###
|
||||||
|
|
||||||
# Removes an {EditSession} association from the project.
|
# Removes an {EditSession} association from the project.
|
||||||
@ -297,8 +301,7 @@ class Project
|
|||||||
options = _.extend(@defaultEditSessionOptions(), editSessionOptions)
|
options = _.extend(@defaultEditSessionOptions(), editSessionOptions)
|
||||||
options.buffer = buffer
|
options.buffer = buffer
|
||||||
editSession = new EditSession(options)
|
editSession = new EditSession(options)
|
||||||
@editSessions.push editSession
|
@addEditSession(editSession)
|
||||||
@trigger 'edit-session-created', editSession
|
|
||||||
editSession
|
editSession
|
||||||
|
|
||||||
defaultEditSessionOptions: ->
|
defaultEditSessionOptions: ->
|
||||||
|
Loading…
Reference in New Issue
Block a user