Skip to content

Commit 2aa1c75

Browse files
committed
Keep newlines in body of task and don't reflow it
1 parent ff1bf2e commit 2aa1c75

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

tasklite-core/source/Lib.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ formatTaskForInfo conf now (taskV, tags, notes) =
13071307
)
13081308
in
13091309
hardline
1310-
<> annotate bold (reflow $ FullTask.body taskV)
1310+
<> annotate bold (pretty taskV.body)
13111311
<> hardline
13121312
<> hardline
13131313
<> ( if P.null tags

tasklite-core/test/LibSpec.hs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ import Test.Hspec (
2424
import Data.Hourglass (DateTime)
2525
import Data.Text qualified as T
2626
import ImportExport (PreEdit (ApplyPreEdit), editTaskByTask)
27-
import Lib (addTag, countTasks, deleteNote, insertRecord, insertTags, newTasks)
27+
import Lib (
28+
addTag,
29+
countTasks,
30+
deleteNote,
31+
infoTask,
32+
insertRecord,
33+
insertTags,
34+
newTasks,
35+
)
2836
import Task (Task (body, closed_utc, state, ulid), TaskState (Done), zeroTask)
2937
import TaskToNote (TaskToNote (TaskToNote))
3038
import TaskToNote qualified
@@ -39,6 +47,17 @@ task1 =
3947
}
4048

4149

50+
taskMultiLine :: Task
51+
taskMultiLine =
52+
zeroTask
53+
{ ulid = "01hx48cnjhp18mts3c44zk3gen"
54+
, body =
55+
"New task\n\
56+
\with several lines\n\
57+
\and line breaks"
58+
}
59+
60+
4261
spec :: DateTime -> Spec
4362
spec now = do
4463
describe "Lib" $ do
@@ -112,6 +131,16 @@ spec now = do
112131
let errMsg = "Tag \"" <> T.unpack existTag <> "\" is already assigned"
113132
show cliOutput `shouldContain` errMsg
114133

134+
it "keeps line breaks of multi-line tasks in info view" $ do
135+
withMemoryDb defaultConfig $ \memConn -> do
136+
insertRecord "tasks" memConn taskMultiLine
137+
138+
cliOutput <- infoTask defaultConfig memConn taskMultiLine.ulid
139+
show cliOutput
140+
`shouldContain` "New task\n\
141+
\with several lines\n\
142+
\and line breaks"
143+
115144
it "lets you delete a note" $ do
116145
withMemoryDb defaultConfig $ \memConn -> do
117146
insertRecord "tasks" memConn task1

0 commit comments

Comments
 (0)