Still lots of signs it's all messed up, but I can't be sure until I bring all the other keyboard shortcuts in sync.
I just need a better data structure that simplifies the logic. Perhaps talk in terms of screen lines. In which case: We'll need to convert lines to screen lines at some point. We'll need to fix up screen lines when inserting and deleting characters.
537TQ2QNPKPG322I4OIMN5IY22S45Z42LEBBZ2IN5MVM355BEJTAC
5L7K4GBDEAFH44LMLNKVFMHLWDNXXBKRPEI347VE5ZLXVFSMD2FAC
SVJZZDC3K6AKAXHGRNAZKRE2ZXEKJANNLG7LSSUZJARFBL5F7C4AC
XNFTJHC4QSHNSIWNN7K6QZEZ37GTQYKHS4EPNSVPQCUSWREROGIQC
H2DPLWMVRFYTO2CQTG54FMT2LF3B6UKLXH32CUA22DNQJVP5XBNQC
BULPIBEGL7TMK6CVIE7IS7WGAHGOSUJBGJSFQK542MOWGHP2ADQQC
WLHI7KD3LJTQH6V7RLVJWGZUR4YQK6LN4OIUMIN45BGMMQGN6RNQC
Y36LOGR5X6S6AEJJ3EBVDC4I3RRFRCZ6GXPXSEIOMVXY2B7UCCGQC
C42QQZSFFGU6DZ73MCPGYZJQ675YTMEOJAPQLHKRJLWQH5GMWHMQC