@@ -24,7 +24,6 @@ import Protolude (
2424 Text ,
2525 Traversable (sequence ),
2626 asum ,
27- decodeUtf8 ,
2827 die ,
2928 fromMaybe ,
3029 hush ,
@@ -77,8 +76,8 @@ import Lib (
7776 execWithConn ,
7877 execWithTask ,
7978 insertNotes ,
79+ insertRecord ,
8080 insertTags ,
81- insertRecord ,
8281 updateTask ,
8382 )
8483import Note (Note (.. ))
@@ -95,7 +94,6 @@ import System.Directory (createDirectoryIfMissing, removeFile)
9594import System.FilePath (takeExtension , (</>) )
9695import System.Posix.User (getEffectiveUserName )
9796import System.Process (readProcess )
98- import System.ReadEditor (readEditorWith )
9997import Task (
10098 Task (
10199 Task ,
@@ -120,6 +118,7 @@ import Task (
120118 textToTaskState ,
121119 zeroTask ,
122120 )
121+ import Text.Editor (runUserEditorDWIM , yamlTemplate )
123122import Text.Parsec.Rfc2822 (GenericMessage (.. ), message )
124123import Text.Parsec.Rfc2822 qualified as Email
125124import Text.ParserCombinators.Parsec as Parsec (parse )
@@ -712,18 +711,15 @@ backupDatabase conf = do
712711
713712editTaskByTask :: Config -> Connection -> Task -> IO (Doc AnsiStyle )
714713editTaskByTask _ 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
718716
719717 if newContent == taskYaml
720718 then
721719 pure $
722720 " ⚠️ Nothing changed" <+> hardline
723721 else do
724722 let
725- newContentBS = P. encodeUtf8 $ T. pack newContent
726-
727723 parseMetadata :: Value -> Parser Bool
728724 parseMetadata val = case val of
729725 Object obj -> do
@@ -735,10 +731,10 @@ editTaskByTask _ connection taskToEdit = do
735731
736732 hasMetadata =
737733 parseMaybe parseMetadata
738- =<< (rightToMaybe $ Yaml. decodeEither' newContentBS :: Maybe Value )
734+ =<< (rightToMaybe $ Yaml. decodeEither' newContent :: Maybe Value )
739735
740736 decodeResult :: Either ParseException ImportTask
741- decodeResult = Yaml. decodeEither' newContentBS
737+ decodeResult = Yaml. decodeEither' newContent
742738
743739 case decodeResult of
744740 Left error -> die $ show error <> " in task \n " <> show newContent
0 commit comments