@@ -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)
@@ -48,10 +52,10 @@ instance Apropos Def where
4852 isApropos str (CaseOp _ ty ty' _ _ _) = isApropos str ty
4953
5054instance Apropos (Binder (TT Name)) where
51− isApropos str (Lam ty) = isApropos str ty
52− isApropos str (Pi ty) = isApropos str ty
53− isApropos str (Let ty val) = isApropos str ty || isApropos str val
54− isApropos str (NLet ty val) = isApropos str ty || isApropos str val
55+ isApropos str (Lam ty) = str == T.pack "\\" || isApropos str ty
56+ isApropos str (Pi ty) = str == T.pack "->" || isApropos str ty
57+ isApropos str (Let ty val) = str == T.pack "let" || isApropos str ty || isApropos str val
58+ isApropos str (NLet ty val) = str == T.pack "let" || isApropos str ty || isApropos str val
5559 isApropos str _ = False -- these shouldn't occur in defined libraries
5660
5761instance Apropos (TT Name) where