From 9ba726831b973ae0f57e640f3a0966da0ca1941d Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Mon, 5 Feb 2024 06:54:16 +0100 Subject: chore: sort match results by source position --- app/Main.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index 41a546f..479f3b0 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -528,15 +528,16 @@ suggestTags settings probabilityCache doc = do case suggestedTag of S.SuggestTagByRE tagName searchReplaces -> let tagValues = - nub . concat $ + nub . map snd . sortBy (comparing fst) . concat $ map ( \searchReplace -> mapMaybe ( -- XXX Whys is this so complicated? \match -> do - captures <- snd <$> R.matchCaptures match + (topCapture, captures) <- R.matchCaptures match pure - ( foldl + ( topCapture.captureOffset, + foldl ( \template (captureName, captureOrdinal) -> T.replace ("${" <> R.getCaptureName captureName <> "}") -- cgit v1.2.3