<commit_before>class CollaborativeEditorPane extends CollaborativePane

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

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

    super options, data

    @panel      = @getDelegate()
    @workspace  = @panel.getDelegate()
    @sessionKey = @getOptions().sessionKey or @createSessionKey()
    @amIHost    = @workspace.amIHost()
    @container  = new KDView

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

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

      @ref.on "value", (snapshot) =>
        return @save()  if snapshot.val().WaitingSaveRequest is yes

      @ref.onDisconnect().remove()  if @amIHost

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

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

    if @amIHost
      return warn "no file instance handle save as" unless isValidFile

      @ref.child("WaitingSaveRequest").set no
      file.save @firepad.getText(), (err, res) =>
        new KDNotificationView
          type     : "mini"
          cssClass : "success"
          title    : "File has been saved"
          duration : 4000
    else
      @ref.child("WaitingSaveRequest").set yes

    @getOptions().saveCallback? @firepad.getText()

  getValue: ->
    return @codeMirrorEditor.getValue()

  createEditor: ->
    @codeMirrorEditor = CodeMirror @container.getDomElement()[0],
      lineNumbers     : yes<commit_msg>Workspace: Added panel, workspace, file params to savedCallback.<commit_after>class CollaborativeEditorPane extends CollaborativePane

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

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

    super options, data

    @panel      = @getDelegate()
    @workspace  = @panel.getDelegate()
    @sessionKey = @getOptions().sessionKey or @createSessionKey()
    @amIHost    = @workspace.amIHost()
    @container  = new KDView

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

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

      @ref.on "value", (snapshot) =>
        return @save()  if snapshot.val().WaitingSaveRequest is yes

      @ref.onDisconnect().remove()  if @amIHost

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

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

    if @amIHost
      return warn "no file instance handle save as" unless isValidFile

      @ref.child("WaitingSaveRequest").set no
      file.save @firepad.getText(), (err, res) =>
        new KDNotificationView
          type     : "mini"
          cssClass : "success"
          title    : "File has been saved"
          duration : 4000
    else
      @ref.child("WaitingSaveRequest").set yes

    @getOptions().saveCallback? @panel, @workspace, file, @firepad.getText()

  getValue: ->
    return @codeMirrorEditor.getValue()

  createEditor: ->
    @codeMirrorEditor = CodeMirror @container.getDomElement()[0],
      lineNumbers     : yes
{'fraction_non_alphanumeric': 0.11690868816145705, 'fraction_numerical': 0.005906965296578882, 'mean_word_length': 2.7284403669724773, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '1891292', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1201, 'n_words': 301}