GitHub

Original file line numberDiff line numberDiff line change

@@ -126,7 +126,7 @@ import Text.PortableLines.ByteString.Lazy (lines8)

126126

import Time.System (dateCurrent, timeCurrent)

127127

import Utils (

128128

IdText,

129-

countChar,

129+

countCharTL,

130130

emptyUlid,

131131

setDateTime,

132132

ulidTextToDateTime,

@@ -215,7 +215,7 @@ parseMarkdownWithFrontMatter content = do

215215

frontMatterYaml = TL.intercalate "\n" frontMatterLines

216216

bodyTextLazy = actualBody & TL.intercalate "\n" & TL.strip

217217

-- Only keep trailing newlines for multiline bodies

218-

noTrailingNewline = countChar '\n' bodyTextLazy == 0

218+

noTrailingNewline = countCharTL '\n' bodyTextLazy == 0

219219

bodyText = bodyTextLazy & TL.toStrict

220220

frontMatterWithBody =

221221

frontMatterYaml

Original file line numberDiff line numberDiff line change

@@ -248,6 +248,7 @@ import Utils (

248248

IdText,

249249

ListModifiedFlag (..),

250250

applyColorMode,

251+

countChar,

251252

dateTimeToUtcTime,

252253

formatElapsedP,

253254

numDigits,

@@ -2406,6 +2407,11 @@ formatTaskLine conf now taskWidth task =

24062407

-- redOut onTime doc = if onTime

24072408

-- then annotate (bodyStyle conf) doc

24082409

-- else annotate (color Red) doc

2410+

taskBody =

2411+

reflow $

2412+

if countChar '\n' task.body > 0

2413+

then (task.body & T.takeWhile (/= '\n')) <> ""

2414+

else task.body

24092415

taskLine =

24102416

createdUtc <&> \taskDate ->

24112417

hang hangWidth $

@@ -2432,8 +2438,8 @@ formatTaskLine conf now taskWidth task =

24322438

else ""

24332439

)

24342440

<> ( if dueIn mempty && isOpen

2435-

then annotate (color Red) (reflow task.body)

2436-

else grayOutIfDone (reflow task.body)

2441+

then annotate (color Red) taskBody

2442+

else grayOutIfDone taskBody

24372443

)

24382444

, annotate (dueStyle conf) (pretty dueUtcMaybe)

24392445

, annotate (closedStyle conf) (pretty closedUtcMaybe)

Original file line numberDiff line numberDiff line change

@@ -62,16 +62,8 @@ import Data.Hourglass (

6262

timeParse,

6363

timePrint,

6464

)

65-

import Data.Text as T (

66-

Text,

67-

chunksOf,

68-

drop,

69-

intercalate,

70-

pack,

71-

take,

72-

toLower,

73-

unpack,

74-

)

65+

import Data.Text (Text, unpack)

66+

import Data.Text qualified as T

7567

import Data.Text.Lazy qualified as TL

7668

import Data.Time (UTCTime, ZonedTime, addUTCTime, zonedTimeToUTC)

7769

import Data.Time.Clock.POSIX (posixSecondsToUTCTime, utcTimeToPOSIXSeconds)

@@ -344,6 +336,11 @@ applyColorMode conf = do

344336

else conf

345337
346338
347-

countChar :: Char -> TL.Text -> P.Int64

348-

countChar char =

339+

countCharTL :: Char -> TL.Text -> P.Int64

340+

countCharTL char =

349341

TL.filter (== char) >>> TL.length

342+
343+
344+

countChar :: Char -> Text -> P.Int

345+

countChar char =

346+

T.filter (== char) >>> T.length

Original file line numberDiff line numberDiff line change

@@ -612,6 +612,14 @@ spec = do

612612

metadata `shouldBe` SQLNull

613613

_ -> P.die "Found more than one task"

614614
615+

it "only shows first line of multi-line tasks in task listing" $ do

616+

withMemoryDb defaultConfig $ \memConn -> do

617+

insertRecord "tasks" memConn taskMultiLine

618+
619+

tasks <- headTasks conf now memConn Nothing

620+

show tasks `shouldContain` "New task ▼"

621+

show tasks `shouldNotContain` "with several lines"

622+
615623

it "keeps line breaks of multi-line tasks in info view" $ do

616624

withMemoryDb defaultConfig $ \memConn -> do

617625

insertRecord "tasks" memConn taskMultiLine

Read the original on github.com ↗