aboutsummaryrefslogtreecommitdiffstats
path: root/app/Issue.hs
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-11-28 13:06:48 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-11-28 13:10:07 +0100
commit739c0d06b63bed7619b39eb189c5e5a34fd8da49 (patch)
tree0c4c0f39ccce82f5a325045db3c043c699e5c907 /app/Issue.hs
parentc138fb9910c661f7efd00cc7dceb6fc68dc790a9 (diff)
editing issues preserves comment style
Diffstat (limited to 'app/Issue.hs')
-rw-r--r--app/Issue.hs9
1 files changed, 4 insertions, 5 deletions
diff --git a/app/Issue.hs b/app/Issue.hs
index 411e910..73122ef 100644
--- a/app/Issue.hs
+++ b/app/Issue.hs
@@ -16,6 +16,7 @@ import GHC.Generics (Generic)
import GHC.Records (HasField (..))
import Issue.Provenance (Author (..), Commit (..), Provenance (..))
import Issue.Tag (Tag (..))
+import TreeGrepper.Comment qualified as G
import TreeGrepper.Match qualified as G
import Prelude hiding (id)
@@ -28,7 +29,8 @@ data Issue = Issue
end :: G.Position,
tags :: [Tag],
markers :: [T.Text],
- rawText :: T.Text
+ rawText :: T.Text,
+ commentStyle :: G.CommentStyle
}
deriving (Show, Binary, Generic, Eq)
@@ -58,13 +60,10 @@ toSpinalCase = T.replace " " "-" . T.filter keep . T.toLower
where
keep = (`elem` (concat [[' ', '-'], ['a' .. 'z'], ['0' .. '9']]))
--- TODO `replaceFile` hardcodes comment
---
--- @difficulty easy
replaceText :: Issue -> T.Text -> IO ()
replaceText issue s' = T.writeFile issue.file . replace (indent (comment s')) =<< T.readFile issue.file
where
- comment = T.intercalate "\n" . map T.strip . map ("-- " <>) . T.lines
+ comment = T.intercalate "\n" . map T.strip . T.lines . G.comment issue.commentStyle
indent = T.intercalate "\n" . mapButFirst (T.replicate (issue.start.column - 1) " " <>) . T.lines
replace s t = before <> s <> after
where