Don't delete the last line if the selection ends right at the beginning

For #7075. Note that this is a fix in master. I haven't looked at the fix in cmv4 yet - it might be different.