on develop help sign in
address comments
53abc34pdlla
src/Data/Text/Zipper.hs+2−1
@@ -365,6 +365,7 @@ wrapWithOffsetAndAlignment
365 -> [WrappedLine] -- (words on that line, hidden space char, offset from beginning of line)
365 -> [WrappedLine] -- (words on that line, hidden space char, offset from beginning of line)
366wrapWithOffsetAndAlignment _ maxWidth _ _ | maxWidth <= 0 = []
366wrapWithOffsetAndAlignment _ maxWidth _ _ | maxWidth <= 0 = []
367wrapWithOffsetAndAlignment alignment maxWidth n txt = assert (n <= maxWidth) r where
367wrapWithOffsetAndAlignment alignment maxWidth n txt = assert (n <= maxWidth) r where
368+ -- we pad by offset amount with any non-space character which we will remove later so that no changes need to be made to splitWordsAtDisplayWidth
368 r' = splitWordsAtDisplayWidth maxWidth $ wordsWithWhitespace ( T.replicate n "." <> txt)
369 r' = splitWordsAtDisplayWidth maxWidth $ wordsWithWhitespace ( T.replicate n "." <> txt)
369 fmapfn (t,b) = case alignment of
370 fmapfn (t,b) = case alignment of
370 TextAlignment_Left -> WrappedLine t b 0
371 TextAlignment_Left -> WrappedLine t b 0
@@ -378,7 +379,7 @@ wrapWithOffsetAndAlignment alignment maxWidth n txt = assert (n <= maxWidth) r w
378
379
379-- converts deleted eol spaces into logical lines
380-- converts deleted eol spaces into logical lines
380eolSpacesToLogicalLines :: [[WrappedLine]] -> [[(Text, Int)]]
381eolSpacesToLogicalLines :: [[WrappedLine]] -> [[(Text, Int)]]
381−eolSpacesToLogicalLines = fmap (fmap (\(WrappedLine a _ c) -> (a,c))) . ((L.groupBy (\(WrappedLine _ b _) _ -> not b)) =<<)
382+eolSpacesToLogicalLines = fmap (fmap (\(WrappedLine a _ c) -> (a,c))) . concatMap (L.groupBy (\(WrappedLine _ b _) _ -> not b))
382
383
383offsetMapWithAlignmentInternal :: [[WrappedLine]] -> OffsetMapWithAlignment
384offsetMapWithAlignmentInternal :: [[WrappedLine]] -> OffsetMapWithAlignment
384offsetMapWithAlignmentInternal = offsetMapWithAlignment . eolSpacesToLogicalLines
385offsetMapWithAlignmentInternal = offsetMapWithAlignment . eolSpacesToLogicalLines
test/Data/Text/ZipperSpec.hs+3
@@ -40,6 +40,9 @@ spec =
40 wrapWithOffsetAndAlignment TextAlignment_Right 5 0 someSentence `shouldBe` [(WrappedLine "12345" True 0), (WrappedLine "1234" True 1), (WrappedLine "12" False 3)]
40 wrapWithOffsetAndAlignment TextAlignment_Right 5 0 someSentence `shouldBe` [(WrappedLine "12345" True 0), (WrappedLine "1234" True 1), (WrappedLine "12" False 3)]
41 wrapWithOffsetAndAlignment TextAlignment_Center 5 0 someSentence `shouldBe` [(WrappedLine "12345" True 0), (WrappedLine "1234" True 0), (WrappedLine "12" False 1)]
41 wrapWithOffsetAndAlignment TextAlignment_Center 5 0 someSentence `shouldBe` [(WrappedLine "12345" True 0), (WrappedLine "1234" True 0), (WrappedLine "12" False 1)]
42 wrapWithOffsetAndAlignment TextAlignment_Left 5 1 someSentence `shouldBe` [(WrappedLine "1234" False 0), (WrappedLine "5" True 0), (WrappedLine "1234" True 0), (WrappedLine "12" False 0)]
42 wrapWithOffsetAndAlignment TextAlignment_Left 5 1 someSentence `shouldBe` [(WrappedLine "1234" False 0), (WrappedLine "5" True 0), (WrappedLine "1234" True 0), (WrappedLine "12" False 0)]
43+
44+ -- leading spaces and offset case
45+ wrapWithOffsetAndAlignment TextAlignment_Left 5 1 (" " <> someSentence) `shouldBe` [(WrappedLine " " True 0), (WrappedLine "12345" True 0), (WrappedLine "1234" True 0), (WrappedLine "12" False 0)]
43 it "eolSpacesToLogicalLines" $ do
46 it "eolSpacesToLogicalLines" $ do
44 eolSpacesToLogicalLines
47 eolSpacesToLogicalLines
45 [
48 [