function computeDiff(acediff3, diffType, leftEditor, rightEditor, offsetLeft, offsetRight, diffText) {
  let lineInfo = {};

  // this was added in to hack around an oddity with the Google lib. Sometimes it would include a newline
  // as the first char for a diff, other times not - and it would change when you were typing on-the-fly. This
  // is used to level things out so the diffs don't appear to shift around
  let newContentStartsWithNewline = /^\n/.test(diffText);

  if (diffType === C.DIFF_INSERT) {
    // pretty confident this returns the right stuff for the left editor: start & end line & char
    var info = getSingleDiffInfo(leftEditor, offsetLeft, diffText);

    // this is the ACTUAL undoctored current line in the other editor. It's always right. Doesn't mean it's
    // going to be used as the start line for the diff though.
    var currentLineOtherEditor = getLineForCharPosition(rightEditor, offsetRight);
    var numCharsOnLineOtherEditor = getCharsOnLine(rightEditor, currentLineOtherEditor);
    const numCharsOnLeftEditorStartLine = getCharsOnLine(leftEditor, info.startLine);
    var numCharsOnLine = getCharsOnLine(leftEditor, info.startLine);

    // this is necessary because if a new diff starts on the FIRST char of the left editor, the diff can comes
    // back from google as being on the last char of the previous line so we need to bump it up one
    let rightStartLine = currentLineOtherEditor;
    if (numCharsOnLine === 0 && newContentStartsWithNewline) {
      newContentStartsWithNewline = false;
    }
    if (info.startChar === 0 && isLastChar(rightEditor, offsetRight, newContentStartsWithNewline)) {
      rightStartLine = currentLineOtherEditor + 1;
    }

    var sameLineInsert = info.startLine === info.endLine;

    // whether or not this diff is a plain INSERT into the other editor, or overwrites a line take a little work to
    // figure out. This feels like the hardest part of the entire script.
    var numRows = 0;
    if (

      // dense, but this accommodates two scenarios:
      // 1. where a completely fresh new line is being inserted in left editor, we want the line on right to stay a 1px line
      // 2. where a new character is inserted at the start of a newline on the left but the line contains other stuff,
      //    we DO want to make it a full line
      (info.startChar > 0 || (sameLineInsert && diffText.length < numCharsOnLeftEditorStartLine))

      // if the right editor line was empty, it's ALWAYS a single line insert [not an OR above?]
      && numCharsOnLineOtherEditor > 0

      // if the text being inserted starts mid-line
      && (info.startChar < numCharsOnLeftEditorStartLine)) {
      numRows++;
    }

    lineInfo = {
      leftStartLine: info.startLine,
      leftEndLine: info.endLine + 1,
      rightStartLine,
      rightEndLine: rightStartLine + numRows,
    };
  } else {
    var info = getSingleDiffInfo(rightEditor, offsetRight, diffText);

    var currentLineOtherEditor = getLineForCharPosition(leftEditor, offsetLeft);
    var numCharsOnLineOtherEditor = getCharsOnLine(leftEditor, currentLineOtherEditor);
    const numCharsOnRightEditorStartLine = getCharsOnLine(rightEditor, info.startLine);
    var numCharsOnLine = getCharsOnLine(rightEditor, info.startLine);

    // this is necessary because if a new diff starts on the FIRST char of the left editor, the diff can comes
    // back from google as being on the last char of the previous line so we need to bump it up one
    let leftStartLine = currentLineOtherEditor;
    if (numCharsOnLine === 0 && newContentStartsWithNewline) {
      newContentStartsWithNewline = false;
    }
    if (info.startChar === 0 && isLastChar(leftEditor, offsetLeft, newContentStartsWithNewline)) {
      leftStartLine = currentLineOtherEditor + 1;
    }

    var sameLineInsert = info.startLine === info.endLine;
    var numRows = 0;
    if (

      // dense, but this accommodates two scenarios:
      // 1. where a completely fresh new line is being inserted in left editor, we want the line on right to stay a 1px line
      // 2. where a new character is inserted at the start of a newline on the left but the line contains other stuff,
      //    we DO want to make it a full line
      (info.startChar > 0 || (sameLineInsert && diffText.length < numCharsOnRightEditorStartLine))

      // if the right editor line was empty, it's ALWAYS a single line insert [not an OR above?]
      && numCharsOnLineOtherEditor > 0

      // if the text being inserted starts mid-line
      && (info.startChar < numCharsOnRightEditorStartLine)) {
      numRows++;
    }

    lineInfo = {
      leftStartLine,
      leftEndLine: leftStartLine + numRows,
      rightStartLine: info.startLine,
      rightEndLine: info.endLine + 1,
    };
  }

  return lineInfo;
}
/**
 // eslint-disable-next-line max-len
 * This method takes the raw diffing info from the Google lib and returns a nice clean object of the following
 * form:
 * {
 *   leftStartLine:
 *   leftEndLine:
 *   rightStartLine:
 *   rightEndLine:
 * }
 *
 * Ultimately, that's all the info we need to highlight the appropriate lines in the left + right editor, add the
 * SVG connectors, and include the appropriate <<, >> arrows.
 *
 * Note: leftEndLine and rightEndLine are always the start of the NEXT line, so for a single line diff, there will
 * be 1 separating the startLine and endLine values. So if leftStartLine === leftEndLine or rightStartLine ===
 * rightEndLine, it means that new content from the other editor is being inserted and a single 1px line will be
 * drawn.
 */


Ultimately, that's all the info we need to highlight the appropriate lines in the left + right editor, add the
SVG connectors, and include the appropriate <<, >> arrows.

leftEndLine and rightEndLine are always the start of the NEXT line, so for a single line diff, there will
be 1 separating the startLine and endLine values. So if leftStartLine === leftEndLine or rightStartLine
rightEndLine, it means that new content from the other editor is being inserted and a single 1px line will be
drawn.
Ultimately that ' s all the info we need to highlight the appropriate lines in the left + right editor add the SVG connectors and include the appropriate << >> arrows . leftEndLine and rightEndLine are always the start of the NEXT line so for a single line diff there will be 1 separating the startLine and endLine values . So if leftStartLine === leftEndLine or rightStartLine rightEndLine it means that new content from the other editor is being inserted and a single 1px line will be drawn .
function computeDiff(acediff3, diffType, leftEditor, rightEditor, offsetLeft, offsetRight, diffText) {
  let lineInfo = {};
  let newContentStartsWithNewline = /^\n/.test(diffText);
  if (diffType === C.DIFF_INSERT) {
    var info = getSingleDiffInfo(leftEditor, offsetLeft, diffText);
    var currentLineOtherEditor = getLineForCharPosition(rightEditor, offsetRight);
    var numCharsOnLineOtherEditor = getCharsOnLine(rightEditor, currentLineOtherEditor);
    const numCharsOnLeftEditorStartLine = getCharsOnLine(leftEditor, info.startLine);
    var numCharsOnLine = getCharsOnLine(leftEditor, info.startLine);
    let rightStartLine = currentLineOtherEditor;
    if (numCharsOnLine === 0 && newContentStartsWithNewline) {
      newContentStartsWithNewline = false;
    }
    if (info.startChar === 0 && isLastChar(rightEditor, offsetRight, newContentStartsWithNewline)) {
      rightStartLine = currentLineOtherEditor + 1;
    }
    var sameLineInsert = info.startLine === info.endLine;
    var numRows = 0;
    if (
      (info.startChar > 0 || (sameLineInsert && diffText.length < numCharsOnLeftEditorStartLine))
      && numCharsOnLineOtherEditor > 0
      && (info.startChar < numCharsOnLeftEditorStartLine)) {
      numRows++;
    }
    lineInfo = {
      leftStartLine: info.startLine,
      leftEndLine: info.endLine + 1,
      rightStartLine,
      rightEndLine: rightStartLine + numRows,
    };
  } else {
    var info = getSingleDiffInfo(rightEditor, offsetRight, diffText);
    var currentLineOtherEditor = getLineForCharPosition(leftEditor, offsetLeft);
    var numCharsOnLineOtherEditor = getCharsOnLine(leftEditor, currentLineOtherEditor);
    const numCharsOnRightEditorStartLine = getCharsOnLine(rightEditor, info.startLine);
    var numCharsOnLine = getCharsOnLine(rightEditor, info.startLine);
    let leftStartLine = currentLineOtherEditor;
    if (numCharsOnLine === 0 && newContentStartsWithNewline) {
      newContentStartsWithNewline = false;
    }
    if (info.startChar === 0 && isLastChar(leftEditor, offsetLeft, newContentStartsWithNewline)) {
      leftStartLine = currentLineOtherEditor + 1;
    }
    var sameLineInsert = info.startLine === info.endLine;
    var numRows = 0;
    if (
      (info.startChar > 0 || (sameLineInsert && diffText.length < numCharsOnRightEditorStartLine))
      && numCharsOnLineOtherEditor > 0
      && (info.startChar < numCharsOnRightEditorStartLine)) {
      numRows++;
    }
    lineInfo = {
      leftStartLine,
      leftEndLine: leftStartLine + numRows,
      rightStartLine: info.startLine,
      rightEndLine: info.endLine + 1,
    };
  }
  return lineInfo;
}
function computeDiff ( acediff3 , diffType , leftEditor , rightEditor , offsetLeft , offsetRight , diffText ) { let lineInfo = { } ; let newContentStartsWithNewline = / ^\n / . test ( diffText ) ; if ( diffType === C . DIFF_INSERT ) { var info = getSingleDiffInfo ( leftEditor , offsetLeft , diffText ) ; var currentLineOtherEditor = getLineForCharPosition ( rightEditor , offsetRight ) ; var numCharsOnLineOtherEditor = getCharsOnLine ( rightEditor , currentLineOtherEditor ) ; const numCharsOnLeftEditorStartLine = getCharsOnLine ( leftEditor , info . startLine ) ; var numCharsOnLine = getCharsOnLine ( leftEditor , info . startLine ) ; let rightStartLine = currentLineOtherEditor ; if ( numCharsOnLine === 0 && newContentStartsWithNewline ) { newContentStartsWithNewline = false ; } if ( info . startChar === 0 && isLastChar ( rightEditor , offsetRight , newContentStartsWithNewline ) ) { rightStartLine = currentLineOtherEditor + 1 ; } var sameLineInsert = info . startLine === info . endLine ; var numRows = 0 ; if ( ( info . startChar > 0 || ( sameLineInsert && diffText . length < numCharsOnLeftEditorStartLine ) ) && numCharsOnLineOtherEditor > 0 && ( info . startChar < numCharsOnLeftEditorStartLine ) ) { numRows ++ ; } lineInfo = { leftStartLine : info . startLine , leftEndLine : info . endLine + 1 , rightStartLine , rightEndLine : rightStartLine + numRows , } ; } else { var info = getSingleDiffInfo ( rightEditor , offsetRight , diffText ) ; var currentLineOtherEditor = getLineForCharPosition ( leftEditor , offsetLeft ) ; var numCharsOnLineOtherEditor = getCharsOnLine ( leftEditor , currentLineOtherEditor ) ; const numCharsOnRightEditorStartLine = getCharsOnLine ( rightEditor , info . startLine ) ; var numCharsOnLine = getCharsOnLine ( rightEditor , info . startLine ) ; let leftStartLine = currentLineOtherEditor ; if ( numCharsOnLine === 0 && newContentStartsWithNewline ) { newContentStartsWithNewline = false ; } if ( info . startChar === 0 && isLastChar ( leftEditor , offsetLeft , newContentStartsWithNewline ) ) { leftStartLine = currentLineOtherEditor + 1 ; } var sameLineInsert = info . startLine === info . endLine ; var numRows = 0 ; if ( ( info . startChar > 0 || ( sameLineInsert && diffText . length < numCharsOnRightEditorStartLine ) ) && numCharsOnLineOtherEditor > 0 && ( info . startChar < numCharsOnRightEditorStartLine ) ) { numRows ++ ; } lineInfo = { leftStartLine , leftEndLine : leftStartLine + numRows , rightStartLine : info . startLine , rightEndLine : info . endLine + 1 , } ; } return lineInfo ; }
eslint-disable-next-line max-len
 This method takes the raw diffing info from the Google lib and returns a nice clean object of the following
 form:
 {
   leftStartLine:
   leftEndLine:
   rightStartLine:
   rightEndLine:
 }
eslint - disable - next - line max - len This method takes the raw diffing info from the Google lib and returns a nice clean object of the following form : { leftStartLine : leftEndLine : rightStartLine : rightEndLine : }
// this was added in to hack around an oddity with the Google lib. Sometimes it would include a newline // as the first char for a diff, other times not - and it would change when you were typing on-the-fly. This // is used to level things out so the diffs don't appear to shift around // pretty confident this returns the right stuff for the left editor: start & end line & char // this is the ACTUAL undoctored current line in the other editor. It's always right. Doesn't mean it's // going to be used as the start line for the diff though. // this is necessary because if a new diff starts on the FIRST char of the left editor, the diff can comes // back from google as being on the last char of the previous line so we need to bump it up one // whether or not this diff is a plain INSERT into the other editor, or overwrites a line take a little work to // figure out. This feels like the hardest part of the entire script. // dense, but this accommodates two scenarios: // 1. where a completely fresh new line is being inserted in left editor, we want the line on right to stay a 1px line // 2. where a new character is inserted at the start of a newline on the left but the line contains other stuff, //    we DO want to make it a full line // if the right editor line was empty, it's ALWAYS a single line insert [not an OR above?] // if the text being inserted starts mid-line // this is necessary because if a new diff starts on the FIRST char of the left editor, the diff can comes // back from google as being on the last char of the previous line so we need to bump it up one // dense, but this accommodates two scenarios: // 1. where a completely fresh new line is being inserted in left editor, we want the line on right to stay a 1px line // 2. where a new character is inserted at the start of a newline on the left but the line contains other stuff, //    we DO want to make it a full line // if the right editor line was empty, it's ALWAYS a single line insert [not an OR above?] // if the text being inserted starts mid-line