on master help sign in
Merge pull request #2104 from japesinator/nothing-found

Clarify failing searches

commit1e719ce4ce988bb9bfd1a122c958d3da4ec96d8d authorDavid Christiansen <david@davidchristiansen.dk> dateFri 3 Apr 2015, 13:57 (12 years ago) parent018ad5bd89af9c
3 files changed+13−9
CONTRIBUTORS+1 src/Idris/REPL.hs+5−4 src/Idris/TypeSearch.hs+7−5
CONTRIBUTORS+1
@@ -32,6 +32,7 @@ Adam Sandberg Eriksson
3232Seo Sanghyeon
3333Benjamin Saunders
3434Alexander Shabalin
35+JP Smith
3536startling
3637Chetan T
3738Matúš Tejiščák
src/Idris/REPL.hs+5−4
@@ -1229,10 +1229,11 @@ process fn (Apropos pkgs a) =
12291229 delabTy ist n,
12301230 fmap (overview . fst) (lookupCtxtExact n (idris_docstrings ist)))
12311231 | n <- sort names, isUN n ]
1232− iRenderResult $ vsep (map (\(m, d) -> text "Module" <+> text m <$>
1233− ppD ist d <> line) mods) <$>
1234− vsep (map (prettyDocumentedIst ist) aproposInfo)
1235− putIState orig
1232+ if (not (null mods)) || (not (null aproposInfo))
1233+ then iRenderResult $ vsep (map (\(m, d) -> text "Module" <+> text m <$>
1234+ ppD ist d <> line) mods) <$>
1235+ vsep (map (prettyDocumentedIst ist) aproposInfo)
1236+ else iRenderError $ text "No results found"
12361237 where isUN (UN _) = True
12371238 isUN (NS n _) = isUN n
12381239 isUN _ = False
src/Idris/TypeSearch.hs+7−5
@@ -30,7 +30,7 @@ import Idris.Core.Unify (match_unify)
3030import Idris.Delaborate (delabTy)
3131import Idris.Docstrings (noDocs, overview)
3232import Idris.Elab.Type (elabType)
33−import Idris.Output (iputStrLn, iRenderOutput, iPrintResult, iRenderResult, prettyDocumentedIst)
33+import Idris.Output (iputStrLn, iRenderOutput, iPrintResult, iRenderError, iRenderResult, prettyDocumentedIst)
3434import Idris.IBC
3535
3636import Prelude hiding (pred)
@@ -54,10 +54,12 @@ searchByType pkgs pterm = do
5454 [ let docInfo = (n, delabTy i n, fmap (overview . fst) (lookupCtxtExact n (idris_docstrings i))) in
5555 displayScore theScore <> char ' ' <> prettyDocumentedIst i docInfo
5656 | (n, theScore) <- names']
57− case idris_outputmode i of
58− RawOutput _ -> do mapM_ iRenderOutput docs
59− iPrintResult ""
60− IdeMode _ _ -> iRenderResult (vsep docs)
57+ if (not (null docs))
58+ then case idris_outputmode i of
59+ RawOutput _ -> do mapM_ iRenderOutput docs
60+ iPrintResult ""
61+ IdeMode _ _ -> iRenderResult (vsep docs)
62+ else iRenderError $ text "No results found"
6163 putIState i -- don't actually make any changes
6264 where
6365 numLimit = 50