getLineText method
Gets the text content of a specific line.
lineIndex is zero-based (0 for the first line).
Returns the text of the line without the newline character.
Implementation
String getLineText(int lineIndex) {
if (_bufferLineIndex != null && _bufferDirty) {
_cachedBufferLines ??= _bufferLineText!.split('\n');
final newLines = _cachedBufferLines!.length - 1;
if (newLines > 0) {
if (lineIndex >= _bufferLineIndex! &&
lineIndex <= _bufferLineIndex! + newLines) {
return _cachedBufferLines![lineIndex - _bufferLineIndex!];
} else if (lineIndex > _bufferLineIndex! + newLines) {
return _rope.getLineText(lineIndex - newLines);
} else {
return _rope.getLineText(lineIndex);
}
} else {
if (lineIndex == _bufferLineIndex) {
return _bufferLineText!;
}
}
}
return _rope.getLineText(lineIndex);
}