mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-14 04:29:04 +03:00
Only emit editor-open event once (on first attachment)
This commit is contained in:
parent
800f16bb29
commit
eaf7ee8ec1
@ -52,16 +52,19 @@ describe "Editor", ->
|
||||
expect(newEditor.editSessions[0]).not.toBe(editor.editSessions[0])
|
||||
|
||||
describe "editor-open event", ->
|
||||
it 'triggers an editor-open event when it is added to the DOM', ->
|
||||
it 'only triggers an editor-open event when it is first added to the DOM', ->
|
||||
openHandler = jasmine.createSpy('openHandler')
|
||||
editor.on 'editor-open', openHandler
|
||||
|
||||
editor.simulateDomAttachment()
|
||||
|
||||
expect(openHandler).toHaveBeenCalled()
|
||||
[event, eventEditor] = openHandler.argsForCall[0]
|
||||
expect(eventEditor).toBe editor
|
||||
|
||||
openHandler.reset()
|
||||
editor.simulateDomAttachment()
|
||||
expect(openHandler).not.toHaveBeenCalled()
|
||||
|
||||
describe "text rendering", ->
|
||||
it "creates a line element for each line in the buffer with the html-escaped text of the line", ->
|
||||
expect(editor.lines.find('.line').length).toEqual(buffer.numLines())
|
||||
|
@ -201,7 +201,9 @@ class Editor extends View
|
||||
else
|
||||
@gutter.addClass('drop-shadow')
|
||||
|
||||
@on 'attach', =>
|
||||
@on 'attach', (e) =>
|
||||
return if @attached
|
||||
@attached = true
|
||||
@calculateDimensions()
|
||||
@hiddenInput.width(@charWidth)
|
||||
@setMaxLineLength() if @softWrap
|
||||
|
Loading…
Reference in New Issue
Block a user