Add tests and implementations to get selected ranges and connect
selected ranges.