Ah, I hadn't thought about when selections are outside the viewport.

I think @redmunds suggestion was: find the first and last selection that are in the viewport. Then, on move line up, if the first selection in the viewport crosses the top viewport boundary, then scroll up, otherwise do nothing. On move line down, if the last selection in the viewport crosses the bottom viewport boundary, then scroll down, otherwise do nothing.