fix cursor keys in long lines wrapped in markdown

closes #5467 

pinging @ellisonbg and @jdfreder who reported the bug