Skip to content

Commit c2f6c19

Browse files
authored
Implement stripPrefix via T.stripPrefix (#2645)
1 parent 0905e68 commit c2f6c19

File tree

1 file changed

+3
-6
lines changed
  • ghcide/src/Development/IDE/Plugin/Completions

1 file changed

+3
-6
lines changed

ghcide/src/Development/IDE/Plugin/Completions/Logic.hs

+3-6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import Data.Function (on)
3131
import Data.Functor
3232
import qualified Data.HashMap.Strict as HM
3333
import qualified Data.HashSet as HashSet
34+
import Data.Monoid (First(..))
3435
import Data.Ord (Down (Down))
3536
import qualified Data.Set as Set
3637
import Development.IDE.Core.Compile
@@ -757,12 +758,8 @@ openingBacktick line prefixModule prefixText Position { _character=(fromIntegral
757758
-}
758759
-- TODO: Turn this into an alex lexer that discards prefixes as if they were whitespace.
759760
stripPrefix :: T.Text -> T.Text
760-
stripPrefix name = T.takeWhile (/=':') $ go prefixes
761-
where
762-
go [] = name
763-
go (p:ps)
764-
| T.isPrefixOf p name = T.drop (T.length p) name
765-
| otherwise = go ps
761+
stripPrefix name = T.takeWhile (/=':') $ fromMaybe name $
762+
getFirst $ foldMap (First . (`T.stripPrefix` name)) prefixes
766763

767764
-- | Prefixes that can occur in a GHC OccName
768765
prefixes :: [T.Text]

0 commit comments

Comments
 (0)