lineAndColumnOf static method
Converts the position
index in a buffer
to a line and column tuple.
Implementation
static List<int> lineAndColumnOf(String buffer, int position) {
var line = 1, offset = 0;
for (final token in newlineParser().token().matchesSkipping(buffer)) {
if (position < token.stop) {
return [line, position - offset + 1];
}
line++;
offset = token.stop;
}
return [line, position - offset + 1];
}