detect selection if it contains last measure

fix courtesy of @heuchi
work on grace notes too

fix courtesy of @heuchi