getNodesInSelection method
find all nodes that have their textIndexStart >= start
and startIndex+body.length
<= end
Implementation
List<SimpleNode> getNodesInSelection(int start, int end) {
List<SimpleNode> result = [];
List<NodeV2> toCheck = [this];
while (toCheck.isNotEmpty) {
NodeV2 k = toCheck[0];
toCheck.remove(k);
if (k is SimpleNode) {
// full or partial selection
if ((k.textIndexStart <= start && start <= k.textIndexEnd) ||
(k.textIndexStart <= end && end <= k.textIndexEnd) ||
(start <= k.textIndexStart && k.textIndexEnd <= end)) result.add(k);
} else {
toCheck.addAll(k.children);
}
}
return result;
}