Hi! The following patches fix the remaining manifestations of bug 5061 ("Wrong painting of cursor after newline" http://bugzilla.lyx.org/show_bug.cgi?id=5061). All of the situations being fixed are RTL/LTR boundary cases.
I'm quite confident the first patch is correct, and will commit it if there are no objections. Parts 2 and 3 I'm less certain about -- they do the job, but I can't say that I really like the way they do it, and I'm a bit worried that they may impact performance. It would be great to get some feedback (Vincent? Stefan?). Dov (P.S. let me know if you find this format of sending patches annoying; this is how it's done by default in mercurial, and I find it quite convenient. The patches should apply cleanly with -p1)