<commit_before>class CollaborativeEditorPane extends CollaborativePane

  @cdnRoot = cdnRoot = "https://koding-cdn.s3.amazonaws.com/codemirror/latest"

  constructor: (options = {}, data) ->

    super options, data

    @container.on "viewAppended", =>
      @createEditor =>
        @ref        = @workspace.firebaseRef.child @sessionKey
        @firepad    = Firepad.fromCodeMirror @ref, @codeMirrorEditor

        @firepad.on "ready", =>
          if @firepad.isHistoryEmpty() # fix for a firepad bug
            @firepad.setText " "
            @firepad.setText ""
          @codeMirrorEditor.scrollTo 0, 0
          {file, content} = @getOptions()
          return @openFile file, content  if file

        if @amIHost
          @ref.on "value", (snapshot) =>
            value = @workspace.reviveSnapshot snapshot
            return unless value
            if value.WaitingSaveRequest is yes
              return @save()

  openFile: (file, content) ->
    @setData file
    isLocalFile = file.path.indexOf("localfile") is 0
    content     = "" if @amIHost and isLocalFile

    if @amIHost and not @getOptions().useFirepadContent
      @firepad.setText content

    @codeMirrorEditor.scrollTo 0, 0
    @emit "OpenedAFile", file, content
    @setEditorMode file.getExtension()

  save: ->
    file        = @getData()
    isValidFile = file instanceof FSFile and file.path.indexOf("localfile") is -1
<commit_msg>CollaborativeEditorPane: emit ready after got the firepad.ready<commit_after>class CollaborativeEditorPane extends CollaborativePane

  @cdnRoot = cdnRoot = "https://koding-cdn.s3.amazonaws.com/codemirror/latest"

  constructor: (options = {}, data) ->

    super options, data

    @container.on "viewAppended", =>
      @createEditor =>
        @ref        = @workspace.firebaseRef.child @sessionKey
        @firepad    = Firepad.fromCodeMirror @ref, @codeMirrorEditor

        @firepad.on "ready", =>
          if @firepad.isHistoryEmpty() # fix for a firepad bug
            @firepad.setText " "
            @firepad.setText ""
          @codeMirrorEditor.scrollTo 0, 0
          {file, content} = @getOptions()
          @emit 'ready'
          return @openFile file, content  if file

        if @amIHost
          @ref.on "value", (snapshot) =>
            value = @workspace.reviveSnapshot snapshot
            return unless value
            if value.WaitingSaveRequest is yes
              return @save()

  openFile: (file, content) ->
    @setData file
    isLocalFile = file.path.indexOf("localfile") is 0
    content     = "" if @amIHost and isLocalFile

    if @amIHost and not @getOptions().useFirepadContent
      @firepad.setText content

    @codeMirrorEditor.scrollTo 0, 0
    @emit "OpenedAFile", file, content
    @setEditorMode file.getExtension()

  save: ->
    file        = @getData()
    isValidFile = file instanceof FSFile and file.path.indexOf("localfile") is -1

{'fraction_non_alphanumeric': 0.10466712422786548, 'fraction_numerical': 0.004804392587508579, 'mean_word_length': 2.453791469194313, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6720530', 'n_tokens_mistral': 880, 'n_tokens_neox': 841, 'n_words': 216}