Make it harder for automation script to leave no lines selected
Fix stack corruption when a script tries to select an invalid line