@@ -9,8 +9,8 @@ import Idris.Docstrings (Docstring, containsText)
9import Data.List (nub)
9import Data.List (nub)
10import qualified Data.Text as T
10import qualified Data.Text as T
12−-- | Find definitions that are relevant to some string. Relevance is one or
12+-- | Find definitions that are relevant to all space-delimited components of
13−-- more of the following:
13+-- some string. Relevance is one or more of the following:
15-- * the string is a substring of the name
15-- * the string is a substring of the name
@@ -20,8 +20,12 @@ import qualified Data.Text as T
20apropos :: IState -> T.Text -> [Name]
20apropos :: IState -> T.Text -> [Name]
21apropos ist what = let defs = ctxtAlist (tt_ctxt ist)
21apropos ist what = let defs = ctxtAlist (tt_ctxt ist)
22 docs = toAlist (idris_docstrings ist)
22 docs = toAlist (idris_docstrings ist)
23− in nub (map fst (filter (isApropos what) defs) ++
23+ in nub (map fst (isAproposAll parts defs) ++
24− map fst (filter (isApropos what) docs))
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
26textIn :: T.Text -> T.Text -> Bool
30textIn :: T.Text -> T.Text -> Bool
27textIn a b = T.isInfixOf (T.toLower a) (T.toLower b)
31textIn a b = T.isInfixOf (T.toLower a) (T.toLower b)