@@ -9,8 +9,8 @@ import Idris.Docstrings (Docstring, containsText)
99import Data.List (nub)
1010import qualified Data.Text as T
1111
12−-- | Find definitions that are relevant to some string. Relevance is one or
13−-- more of the following:
12+-- | Find definitions that are relevant to all space-delimited components of
13+-- some string. Relevance is one or more of the following:
1414--
1515-- * the string is a substring of the name
1616--
@@ -20,8 +20,12 @@ import qualified Data.Text as T
2020apropos :: IState -> T.Text -> [Name]
2121apropos ist what = let defs = ctxtAlist (tt_ctxt ist)
2222 docs = toAlist (idris_docstrings ist)
23− in nub (map fst (filter (isApropos what) defs) ++
24− map fst (filter (isApropos what) docs))
23+ in nub (map fst (isAproposAll parts defs) ++
24+ map fst (isAproposAll parts docs))
25+ where isAproposAll [] xs = xs
26+ isAproposAll (what:more) xs = filter (isApropos what)
27+ (isAproposAll more xs)
28+ parts = filter ((> 0) . T.length) . T.splitOn (T.pack " ") $ what
2529
2630textIn :: T.Text -> T.Text -> Bool
2731textIn a b = T.isInfixOf (T.toLower a) (T.toLower b)