From 03d63f6f2d6508b25e056b60839bda91ded15fe0 Mon Sep 17 00:00:00 2001 From: Bodigrim Date: Fri, 28 Jan 2022 00:05:24 +0000 Subject: [PATCH] Implement stripPrefix via T.stripPrefix --- ghcide/src/Development/IDE/Plugin/Completions/Logic.hs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs b/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs index 9ce4c80cd6..f1017eea93 100644 --- a/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs +++ b/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs @@ -31,6 +31,7 @@ import Data.Function (on) import Data.Functor import qualified Data.HashMap.Strict as HM import qualified Data.HashSet as HashSet +import Data.Monoid (First(..)) import Data.Ord (Down (Down)) import qualified Data.Set as Set import Development.IDE.Core.Compile @@ -757,12 +758,8 @@ openingBacktick line prefixModule prefixText Position { _character=(fromIntegral -} -- TODO: Turn this into an alex lexer that discards prefixes as if they were whitespace. stripPrefix :: T.Text -> T.Text -stripPrefix name = T.takeWhile (/=':') $ go prefixes - where - go [] = name - go (p:ps) - | T.isPrefixOf p name = T.drop (T.length p) name - | otherwise = go ps +stripPrefix name = T.takeWhile (/=':') $ fromMaybe name $ + getFirst $ foldMap (First . (`T.stripPrefix` name)) prefixes -- | Prefixes that can occur in a GHC OccName prefixes :: [T.Text]