diff options
Diffstat (limited to 'app/Main.hs')
-rw-r--r-- | app/Main.hs | 25 |
1 files changed, 1 insertions, 24 deletions
diff --git a/app/Main.hs b/app/Main.hs index 2e3cae1..e1b4e18 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -673,7 +673,7 @@ main = do hFlush h hClose h sh_ (proc "${EDITOR-vi} -- %" fp) - replaceText issue =<< T.readFile fp + I.replaceText issue =<< T.readFile fp else do -- TODO Make `show` page-able -- @@ -768,29 +768,6 @@ prettyTags = ) M.empty --- TODO Move `replaceText` to `Issue` - --- 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 - indent = T.intercalate "\n" . mapButFirst (T.replicate (issue.start.column - 1) " " <>) . T.lines - replace s t = before <> s <> after - where - t' = T.lines t - before = T.intercalate "\n" (mapLast (T.take (issue.start.column - 1)) (take issue.start.row t')) - after = T.unlines (mapFirst (T.drop issue.end.column) (drop (issue.end.row - 1) t')) - mapFirst _ [] = [] - mapFirst f (x : xs) = f x : xs - mapLast _ [] = [] - mapLast f [x] = [f x] - mapLast f (x : xs) = x : mapLast f xs - mapButFirst _ [] = [] - mapButFirst f (x : xs) = x : map f xs - putDoc :: Color -> Bool -> Maybe Int -> P.Doc P.AnsiStyle -> IO () putDoc colorize noPager width doc = do isTty <- (== 1) <$> c_isatty 1 |