lineByIndex method

String lineByIndex(
  1. int ix
)

Returns a line given by its index. May be a part of the stored line if the currentRegion requires that.

Implementation

String lineByIndex(int ix) {
  var line = lines[ix];
  if (ix == currentRegion.start.line) {
    if (ix == currentRegion.end.line && currentRegion.end.column != 0) {
      line = line.substring(0, currentRegion.end.column);
    }
  } else if (ix == currentRegion.end.line && currentRegion.end.column != 0) {
    line = line.substring(0, currentRegion.end.column);
  }
  return line;
}