Fix cursor handling

The cursor wouldn't wrap around to the top entry when you hit 'j' on the
last one.