diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 6b30ac670..e4c47638b 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -51,6 +51,17 @@ describe "Editor", -> expect(newEditor.editSessions[0]).toEqual(editor.editSessions[0]) 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', -> + openHandler = jasmine.createSpy('openHandler') + editor.on 'editor-open', openHandler + + editor.simulateDomAttachment() + + expect(openHandler).toHaveBeenCalled() + [event, eventEditor] = openHandler.argsForCall[0] + expect(eventEditor).toBe editor + 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()) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index a793275f7..5f28b5d78 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -206,6 +206,7 @@ class Editor extends View @hiddenInput.width(@charWidth) @setMaxLineLength() if @softWrap @focus() if @isFocused + @trigger 'editor-open', [this] rootView: -> @parents('#root-view').view()