diff options
author | Alexander Foremny <aforemny@posteo.de> | 2023-12-08 06:27:15 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2023-12-08 06:43:01 +0100 |
commit | 0d20548e3846cb80acca07fad2a1dc3cfe024528 (patch) | |
tree | 6605eb393af99914b4cce483f56e1becbcbe073d /app/Issue.hs | |
parent | 5842e730152a2ae11fc8772a505baa3ba81b1e9c (diff) |
chore: drop tree-grepper
Regresses in that we only support Haskell for now, as Elm, Nix or Bash
are not available as tree-sitter-* Haskell packages.
Diffstat (limited to 'app/Issue.hs')
-rw-r--r-- | app/Issue.hs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/app/Issue.hs b/app/Issue.hs index 83e7141..9ae3de8 100644 --- a/app/Issue.hs +++ b/app/Issue.hs @@ -10,6 +10,7 @@ module Issue where import CMark qualified as D +import Comment qualified as G import Data.Binary (Binary (..)) import Data.List.NonEmpty (NonEmpty) import Data.Text qualified as T @@ -21,8 +22,6 @@ import Git (Author (..), Commit (..)) import Issue.Provenance (Provenance (..)) import Issue.Tag (Tag (..)) import Render qualified as P -import TreeGrepper.Comment qualified as G -import TreeGrepper.Match qualified as G import Prelude hiding (id) data Issue = Issue @@ -30,8 +29,8 @@ data Issue = Issue description :: Maybe (NonEmpty D.Node), file :: String, provenance :: Provenance, - start :: G.Position, - end :: G.Position, + startPoint :: G.Point, + endPoint :: G.Point, tags :: [Tag], markers :: [T.Text], rawText :: T.Text, @@ -78,12 +77,12 @@ 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 . T.lines . G.comment issue.commentStyle - indent = T.intercalate "\n" . mapButFirst (T.replicate (issue.start.column - 1) " " <>) . T.lines + indent = T.intercalate "\n" . mapButFirst (T.replicate (issue.startPoint.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')) + before = T.intercalate "\n" (mapLast (T.take (issue.startPoint.column - 1)) (take issue.startPoint.row t')) + after = T.unlines (mapFirst (T.drop issue.endPoint.column) (drop (issue.endPoint.row - 1) t')) mapFirst _ [] = [] mapFirst f (x : xs) = f x : xs mapLast _ [] = [] |