From 4987c7a49aad1fcc9daab201345fd6f15fb8d020 Mon Sep 17 00:00:00 2001 From: CrystalSplitter Date: Thu, 7 Mar 2024 00:55:43 -0800 Subject: [PATCH] Allow apostraphes interspersed in token names It turns out these are also allowed--and thus we need to be able to match on them. --- lib/ghcitui-core/Ghcitui/Ghcid/ParseContext.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ghcitui-core/Ghcitui/Ghcid/ParseContext.hs b/lib/ghcitui-core/Ghcitui/Ghcid/ParseContext.hs index 7bb1f2f..9886723 100644 --- a/lib/ghcitui-core/Ghcitui/Ghcid/ParseContext.hs +++ b/lib/ghcitui-core/Ghcitui/Ghcid/ParseContext.hs @@ -68,9 +68,9 @@ parseFile s -- | Parse a source range structure into a SourceRange object. parseSourceRange :: T.Text -> Loc.SourceRange parseSourceRange s - -- Matches (12,34)-(56,78) + -- Matches (12,34)-(56,78) ... (line 12, column 34 to line 56, column 78) | Just mr <- matches "\\(([0-9]+),([0-9]+)\\)-\\(([0-9]+),([0-9]+)\\)" = fullRange mr - -- Matches 12:34-56 + -- Matches 12:34-56 ... (line 12, columns 34 to 56) | Just mr <- matches "([0-9]+):([0-9]+)-([0-9]+)" = lineColRange mr -- Matches 12:34 | Just mr <- matches "([0-9]+):([0-9]+)" = lineColSingle mr @@ -136,7 +136,7 @@ eInfoLine contextText = mStopLineMatchRes = foldr (\n acc -> acc <|> stopReg n) Nothing splits -- Match on the "Stopped in ..." line. stopReg :: T.Text -> Maybe (MatchResult T.Text) - stopReg s = s =~~ ("^[ \t]*Stopped in ([[:alnum:]_.()]+'*),(.*)" :: T.Text) + stopReg s = s =~~ ("^[ \t]*Stopped in ([[:alnum:]_.()']+),(.*)" :: T.Text) parseBreakResponse :: T.Text -> Either T.Text [Loc.ModuleLoc] parseBreakResponse t @@ -212,7 +212,7 @@ parseShowModules t where stripped = T.strip t matchingLines = mapMaybe matching . T.lines <$> lastMay (splitBy ghcidPrompt stripped) - reg = "([[:alnum:]_.]+)[ \\t]+\\( *([^,]*),.*\\)" :: T.Text + reg = "([[:alnum:]_.']+)[ \\t]+\\( *([^,]*),.*\\)" :: T.Text matching :: T.Text -> Maybe (MatchResult T.Text) matching = (=~~ reg)