@@ -457,6 +457,19 @@ displayLinesWithAlignment alignment width tag cursorTag (TextZipper lb b a la) =
457457 [] -> [[cursor]]
458458 (l:ls) -> (cursor : l) : ls
459459
460+ curLineSpanNormalCase = if cursorAfterEOL
461+ then [ spansCurLineBefore, spansCurLineAfter ]
462+ else [ spansCurLineBefore <> spansCurLineAfter ]
463+
464+ -- for right alignment, we want draw the cursor tag to be on the character just before the logical cursor position
465+ curLineSpan = if alignment == TextAlignment_Right && not cursorAfterEOL
466+ then case reverse spansCurLineBefore of
467+ [] -> curLineSpanNormalCase
468+ (Span _ x):xs -> case spansCurLineAfter of
469+ [] -> error "should not be possible" -- curLineSpanNormalCase
470+ (Span _ y):ys -> [reverse (Span cursorTag x:xs) <> ((Span tag y):ys)]
471+ else curLineSpanNormalCase
472+
460473 cursorY = sum
461474 [ length spansBefore
462475 , length spansCurrentBefore
@@ -469,9 +482,7 @@ displayLinesWithAlignment alignment width tag cursorTag (TextZipper lb b a la) =
469482 { _displayLines_spans = concat
470483 [ spansBefore
471484 , spansCurrentBefore
472− , if cursorAfterEOL
473− then [ spansCurLineBefore, spansCurLineAfter ]
474− else [ spansCurLineBefore <> spansCurLineAfter ]
485+ , curLineSpan
475486 , spansCurrentAfter
476487 , spansAfter
477488 ]