readline: consider newlines for cursor position

Fixes #7266.
Closes #7279.