on develop help sign in
hlint
commitcce5ff5c33bcbf306d253169326b0783a0e86e22 authorpdlla <chippermonky@gmail.com> dateSat 12 Jun 2021, 20:58 (5 years ago) parent494a520
1 file changed+6−8
src/Data/Text/Zipper.hs+6−8
src/Data/Text/Zipper.hs+6−8
@@ -170,7 +170,7 @@ deleteLeftWord (TextZipper lb b a la) =
170170-- | Insert up to n spaces to get to the next logical column that is a multiple of n
171171tab :: Int -> TextZipper -> TextZipper
172172tab n z@(TextZipper _ b _ _) =
173− insert (T.replicate (fromEnum $ n - (T.length b `mod` max 1 n)) " ") z
173+ insert (T.replicate (fromEnum $ n - T.length b `mod` max 1 n) " ") z
174174
175175-- | The plain text contents of the zipper
176176value :: TextZipper -> Text
@@ -314,9 +314,7 @@ wordsWithWhitespace :: Text -> [Text]
314314wordsWithWhitespace t@(Text arr off len) = loop 0 0 False
315315 where
316316 loop !start !n !wasSpace
317− | n >= len = if start == n
318− then []
319− else [Text arr (start+off) (n-start)]
317+ | n >= len = [Text arr (start+off) (n-start) | not (start == n)]
320318 | isSpace c = loop start (n+d) True
321319 | wasSpace = Text arr (start+off) (n-start) : loop n n False
322320 | otherwise = loop start (n+d) False
@@ -380,7 +378,7 @@ wrapWithOffsetAndAlignment alignment maxWidth n txt = assert (n <= maxWidth) r w
380378
381379-- converts deleted eol spaces into logical lines
382380eolSpacesToLogicalLines :: [[WrappedLine]] -> [[(Text, Int)]]
383−eolSpacesToLogicalLines = fmap (fmap (\(WrappedLine a _ c) -> (a,c))) . join . fmap (L.groupBy (\(WrappedLine _ b _) _ -> not b))
381+eolSpacesToLogicalLines = fmap (fmap (\(WrappedLine a _ c) -> (a,c))) . ((L.groupBy (\(WrappedLine _ b _) _ -> not b)) =<<)
384382
385383offsetMapWithAlignmentInternal :: [[WrappedLine]] -> OffsetMapWithAlignment
386384offsetMapWithAlignmentInternal = offsetMapWithAlignment . eolSpacesToLogicalLines
@@ -434,7 +432,7 @@ displayLinesWithAlignment alignment width tag cursorTag (TextZipper lb b a la) =
434432
435433 -- TODO cursor goes here if align right
436434 (spansCurrentBefore, spansCurLineBefore) = fromMaybe ([], []) $
437− initLast $ map ((:[]) . Span tag) $ fmap _wrappedLines_text $ (wrapWithOffsetAndAlignment alignment width 0 b)
435+ initLast $ map ((:[]) . Span tag) $ _wrappedLines_text <$> (wrapWithOffsetAndAlignment alignment width 0 b)
438436 -- Calculate the number of columns on the cursor's display line before the cursor
439437 curLineOffset = spansWidth spansCurLineBefore
440438 -- Check whether the spans on the current display line are long enough that
@@ -455,7 +453,7 @@ displayLinesWithAlignment alignment width tag cursorTag (TextZipper lb b a la) =
455453 Just (c, rest) ->
456454 let o = if cursorAfterEOL then cursorCharWidth else curLineOffset + cursorCharWidth
457455 cursor = Span cursorTag (T.singleton c)
458− in case map ((:[]) . Span tag) $ fmap _wrappedLines_text $ (wrapWithOffsetAndAlignment alignment width o rest) of
456+ in case map ((:[]) . Span tag) $ _wrappedLines_text <$> (wrapWithOffsetAndAlignment alignment width o rest) of
459457 [] -> [[cursor]]
460458 (l:ls) -> (cursor : l) : ls
461459
@@ -531,4 +529,4 @@ wrapWithOffset
531529 -> Int -- ^ Offset for first line
532530 -> Text -- ^ Text to be wrapped
533531 -> [Text]
534−wrapWithOffset maxWidth n xs = fmap _wrappedLines_text $ wrapWithOffsetAndAlignment TextAlignment_Left maxWidth n xs
532+wrapWithOffset maxWidth n xs = _wrappedLines_text <$> wrapWithOffsetAndAlignment TextAlignment_Left maxWidth n xs