@@ -24,7 +24,6 @@ import Protolude (
24
24
Text ,
25
25
Traversable (sequence ),
26
26
asum ,
27
- decodeUtf8 ,
28
27
die ,
29
28
fromMaybe ,
30
29
hush ,
@@ -77,8 +76,8 @@ import Lib (
77
76
execWithConn ,
78
77
execWithTask ,
79
78
insertNotes ,
79
+ insertRecord ,
80
80
insertTags ,
81
- insertRecord ,
82
81
updateTask ,
83
82
)
84
83
import Note (Note (.. ))
@@ -95,7 +94,6 @@ import System.Directory (createDirectoryIfMissing, removeFile)
95
94
import System.FilePath (takeExtension , (</>) )
96
95
import System.Posix.User (getEffectiveUserName )
97
96
import System.Process (readProcess )
98
- import System.ReadEditor (readEditorWith )
99
97
import Task (
100
98
Task (
101
99
Task ,
@@ -120,6 +118,7 @@ import Task (
120
118
textToTaskState ,
121
119
zeroTask ,
122
120
)
121
+ import Text.Editor (runUserEditorDWIM , yamlTemplate )
123
122
import Text.Parsec.Rfc2822 (GenericMessage (.. ), message )
124
123
import Text.Parsec.Rfc2822 qualified as Email
125
124
import Text.ParserCombinators.Parsec as Parsec (parse )
@@ -712,18 +711,15 @@ backupDatabase conf = do
712
711
713
712
editTaskByTask :: Config -> Connection -> Task -> IO (Doc AnsiStyle )
714
713
editTaskByTask _ connection taskToEdit = do
715
- let taskYaml = (T. unpack . decodeUtf8 . Yaml. encode) taskToEdit
716
-
717
- newContent <- readEditorWith taskYaml
714
+ let taskYaml = Yaml. encode taskToEdit
715
+ newContent <- runUserEditorDWIM yamlTemplate taskYaml
718
716
719
717
if newContent == taskYaml
720
718
then
721
719
pure $
722
720
" ⚠️ Nothing changed" <+> hardline
723
721
else do
724
722
let
725
- newContentBS = P. encodeUtf8 $ T. pack newContent
726
-
727
723
parseMetadata :: Value -> Parser Bool
728
724
parseMetadata val = case val of
729
725
Object obj -> do
@@ -735,10 +731,10 @@ editTaskByTask _ connection taskToEdit = do
735
731
736
732
hasMetadata =
737
733
parseMaybe parseMetadata
738
- =<< (rightToMaybe $ Yaml. decodeEither' newContentBS :: Maybe Value )
734
+ =<< (rightToMaybe $ Yaml. decodeEither' newContent :: Maybe Value )
739
735
740
736
decodeResult :: Either ParseException ImportTask
741
- decodeResult = Yaml. decodeEither' newContentBS
737
+ decodeResult = Yaml. decodeEither' newContent
742
738
743
739
case decodeResult of
744
740
Left error -> die $ show error <> " in task \n " <> show newContent
0 commit comments