Avoid range selection on empty groups

This prevents a traceback when the group is empty.
Fixes #6258
Merge pull request #6260 from j2sol/6258

Avoid range selection on empty groups