Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 0585574

Browse files
authored
Merge pull request #1323 from fendor/reuse-unhtml-for-hsimport
Reuse unHTML for searchModules'
2 parents 0c83fe0 + f05ad2f commit 0585574

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/Haskell/Ide/Engine/Plugin/Hoogle.hs

+5-8
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ renderTarget t = T.intercalate "\n" $
141141
annotate :: (String, String) -> String
142142
annotate (thing,url) = "["<>thing<>"]"<>"("<>url<>")"
143143

144+
-- | Hoogle results contain html like tags.
145+
-- We remove them with `tagsoup` here.
146+
-- So, if something hoogle related shows html tags,
147+
-- then maybe this function is responsible.
144148
unHTML :: T.Text -> T.Text
145149
unHTML = T.replace "<0>" "" . innerText . parseTags
146150

@@ -172,21 +176,14 @@ searchModules = fmap (map fst) . searchModules'
172176
searchModules' :: T.Text -> IdeM [(T.Text, T.Text)]
173177
searchModules' = fmap (take 5 . nub) . searchTargets retrieveModuleAndSignature
174178
where
175-
-- | Hoogle results contain html like tags.
176-
-- We remove them with `tagsoup` here.
177-
-- So, if something hoogle related shows html tags,
178-
-- then maybe this function is responsible.
179-
normaliseItem :: T.Text -> T.Text
180-
normaliseItem = innerText . parseTags
181-
182179
retrieveModuleAndSignature :: Target -> Maybe (T.Text, T.Text)
183180
retrieveModuleAndSignature target = liftA2 (,) (packModuleName target) (packSymbolSignature target)
184181

185182
packModuleName :: Target -> Maybe T.Text
186183
packModuleName = fmap (T.pack . fst) . targetModule
187184

188185
packSymbolSignature :: Target -> Maybe T.Text
189-
packSymbolSignature = Just . normaliseItem . T.pack . targetItem
186+
packSymbolSignature = Just . unHTML . T.pack . targetItem
190187

191188
-- | Search for packages that satisfy the given search text.
192189
-- Will return at most five, unique results.

0 commit comments

Comments
 (0)