Fix cases where the current and terminal selector parts are the same

This PR handles cases where the current and terminal selector parts are the same. I believe this fixes #574.