detect selection if it contains last measure

If the selection includes the last measure, it wasn't detected, because rewind(2) sets the cursor behind the end of the score. Thus cursor.segment == null.

For a demonstration:
1) Open some file (at least 2 measures).
2) Select only the whole last measure.
3) Run the plugin. It will write the names on all notes because it didn't identify the selection correctly.