getLineNext method

int getLineNext(
  1. int index
)

Returns the index of the start of the line following the line which contains the given index.

Implementation

int getLineNext(int index) {
  var length = _buffer.length;
  // skip to the end of the line
  while (index < length) {
    var c = _buffer.codeUnitAt(index);
    if (c == 0xD || c == 0xA) {
      break;
    }
    index++;
  }
  // Skip a single '\r'.
  if (index < length && _buffer.codeUnitAt(index) == 0xD) {
    index++;
  }
  // Skip a single '\n'.
  if (index < length && _buffer.codeUnitAt(index) == 0xA) {
    index++;
  }
  // Done.
  return index;
}