src/utility/fillLeafs.js
function getIndentation(str, index) {
  let indentStart = index;
  let indentEnd = index;
  while (indentStart) {
    const c = str.charCodeAt(indentStart - 1);
    // line break
    if (c === 10 || c === 13 || c === 0x2028 || c === 0x2029) {
      break;
    }
    indentStart--;
    // not white space
    if (c !== 9 && c !== 11 && c !== 12 && c !== 32 && c !== 160) {
      indentEnd = indentStart;
    }
  }
  return str.substring(indentStart, indentEnd);
}
function getIndentation(str, index) {
  let indentStart = index;
  let indentEnd = index;
  while (indentStart) {
    const c = str.charCodeAt(indentStart - 1);
    // line break
    if (c === 10 || c === 13 || c === 0x2028 || c === 0x2029) {
      break;
    }
    indentStart--;
    // not white space
    if (c !== 9 && c !== 11 && c !== 12 && c !== 32 && c !== 160) {
      indentEnd = indentStart;
    }
  }
  return str.substring(indentStart, indentEnd);
}
function getIndentation ( str , index ) { let indentStart = index ; let indentEnd = index ; while ( indentStart ) { const c = str . charCodeAt ( indentStart - 1 ) ; // line break if ( c === 10 || c === 13 || c === 0x2028 || c === 0x2029 ) { break ; } indentStart -- ; // not white space if ( c !== 9 && c !== 11 && c !== 12 && c !== 32 && c !== 160 ) { indentEnd = indentStart ; } } return str . substring ( indentStart , indentEnd ) ; }
Given a string and an index, look backwards to find the string of whitespace following the next previous line break.
Given a string and an index look backwards to find the string of whitespace following the next previous line break .