Skip to content

Commit

Permalink
Implement stripPrefix via T.stripPrefix (#2645)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Jan 28, 2022
1 parent 0905e68 commit c2f6c19
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions ghcide/src/Development/IDE/Plugin/Completions/Logic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit c2f6c19

Please sign in to comment.