@@ -12,7 +12,7 @@ module Data.Text.Zipper where
1212import Prelude
1313
1414import Control.Exception (assert)
15−import Control.Monad.State (evalState, forM, get, put, join)
15+import Control.Monad.State (evalState, forM, get, put)
1616import Data.Char (isSpace)
1717import Data.Map (Map)
1818import Data.Maybe (fromMaybe)
@@ -418,10 +418,13 @@ displayLinesWithAlignment alignment width tag cursorTag (TextZipper lb b a la) =
418418 linesBefore = map (wrapWithOffsetAndAlignment alignment width 0) $ reverse lb
419419 linesAfter :: [[WrappedLine]] -- The wrapped lines after the cursor line
420420 linesAfter = map (wrapWithOffsetAndAlignment alignment width 0) la
421+
422+ -- simulate trailing cursor character when computing OffsetMap
423+ afterWithCursor = if T.null a then " " else a
421424 offsets :: OffsetMapWithAlignment
422425 offsets = offsetMapWithAlignmentInternal $ mconcat
423426 [ linesBefore
424− , [wrapWithOffsetAndAlignment alignment width 0 $ b <> a]
427+ , [wrapWithOffsetAndAlignment alignment width 0 $ b <> afterWithCursor]
425428 , linesAfter
426429 ]
427430 flattenLines = concatMap (fmap _wrappedLines_text)