     #TODO: implement this
     console.log "Generate Diff"
     @diffs = []
+
+    positionForCharacterIndex = (offset) =>
+      offset = Math.max(0, offset)
+      offset = Math.min(@offsetIndex.totalTo(Infinity, 'rows').characters, offset)
+
+      {rows, characters} = @offsetIndex.totalTo(offset, 'characters')
+      if rows > @sLines.length - 1
+        lastRow = @sLines.length - 1
+        new Point(lastRow, @sLines[lastRow].length)
+      else
+        new Point(rows, offset - characters)
+
+    computeTable = (x, y)->
+      c = []
+      for i in [0 .. x.length - 1]
+        c[i] = []
+      for i in [0 .. x.length - 1]
+        c[i][0] = 0
+      for j in [0 .. y.length - 1]
+        c[0][j] = 0
+      for i in [1 .. x.length - 1]
+        for j in [1 .. y.length - 1]
+          if x[i] == y[j]
+            c[i][j] = c[i-1][j-1] + 1
+          else
+            c[i][j] = if c[i][j-1] > c[i-1][j] then c[i][j-1] else c[i-1][j]
+      return c
+
+    genDiff = (c, x, y, i, j) =>
+      if i > 0 and j > 0 and x[i] == y[j]
+        genDiff(c, x, y, i-1, j-1)
+        #console.log " " + x[i]
+      else if j > 0 and (i == 0 or c[i][j-1] >= c[i-1][j])
+        console.log "-" + y[j]
+        console.log "Update j - 1:" + (j - 1) + " i - 1:" + (i - 1)
+        console.log "Values y[j]:" + y[j] + " y[i]:" + y[i]
+        oldText = y[j]
+        newText = ""
+        console.log @editor.getBuffer().positionForCharacterIndex(j - 1)
+        console.log positionForCharacterIndex(j - 1)
+        console.log @editor.getBuffer().positionForCharacterIndex(j)
+        console.log positionForCharacterIndex(j)
+        console.log @offsetIndex
+        console.log @editor.getBuffer().offsetIndex
+        console.log @offsetIndex == @editor.getBuffer().offsetIndex
+        oldRange = Range(@editor.getBuffer().positionForCharacterIndex(j - 1), @editor.getBuffer().positionForCharacterIndex(j))
+        newRange = Range(@editor.getBuffer().positionForCharacterIndex(j - 1), @editor.getBuffer().positionForCharacterIndex(j - 1))
+        originFlag = true
+        diff = {oldRange, newRange, oldText, newText, originFlag}
+        console.log diff
+        @diffs.push diff
+        genDiff(c, x, y, i, j - 1)
+      else if i > 0 and (j == 0 or c[i][j-1] < c[i-1][j])
+        genDiff(c, x, y, i-1, j)
+        console.log "+" + x[i]
+        console.log "Update line :" + (i - 1)
+        oldText = ""
+        newText = x[i]
+        oldRange = Range(positionForCharacterIndex(i - 1), positionForCharacterIndex(i - 1))
+        newRange = Range(positionForCharacterIndex(i - 1), positionForCharacterIndex(i))
+        originFlag = true
+        diff = {oldRange, newRange, oldText, newText, originFlag}
+        console.log diff
+        @diffs.push diff
+      else
+        console.log " "
+
+    xText = ''
+    for row in [0 .. @sLines.length - 1]
+      xText += (@sLines[row] + @sLineEndings[row])
+
+    yText = ''
+    for row in [0 .. @editor.getBuffer().getLines().length - 1]
+      yText += (@editor.getBuffer().getLines()[row] + @editor.getBuffer().lineEndings[row])
+
+    x = xText.split("")
+    y = yText.split("")
+    x.unshift("")
+    y.unshift("")
+    genDiff(computeTable(x, y), x, y, x.length - 1, y.length - 1)
+
+
+    #diff = {oldRange, newRange, oldText, newText}
+    #@diffs.push diff
+
 
   changedSelection: (e) ->
 

    lineEndings[lastIndex] = lastLineEnding

    # Replace lines in oldRange with new lines
    spliceArray(@lines, startRow, rowCount, lines)
    spliceArray(@lineEndings, startRow, rowCount, lineEndings)

    # Update the offset index for position <-> character offset translation
    offsets = lines.map (line, index) ->

    @disposables.push @editor.onDidChangeSelectionRange (e) =>
      @changedSelection e

    @sLines = @editor.getBuffer().getLines().slice()
    @sLineEndings = @editor.getBuffer().lineEndings.slice()

    @offsetIndex = new SpanSkipList('rows', 'characters')
    offsets = @sLines.map (line, index) =>
      {rows: 1, characters: line.length + @sLineEndings[index].length}
    @offsetIndex.spliceArray('rows', 0, @sLines.length, offsets)

    try
      super params
    catch error
      console.log error

  destructor: ->
    for d in @disposables
      d.dispose()

    super()

  getName: -> @name

  internalChange: (e) ->
    if @pmutex and @icb.length > 0
