Skip to content

Commit ea593a2

Browse files
committed
Fixes
1 parent 5412881 commit ea593a2

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

ghcide/src/Development/IDE/Core/Compile.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1652,7 +1652,7 @@ lookupName :: HscEnv
16521652
-> IO (Maybe TyThing)
16531653
lookupName _ name
16541654
| Nothing <- nameModule_maybe name = pure Nothing
1655-
lookupName hsc_env name = do
1655+
lookupName hsc_env name = handle $ do
16561656
#if MIN_VERSION_ghc(9,2,0)
16571657
mb_thing <- liftIO $ lookupType hsc_env name
16581658
#else
@@ -1671,6 +1671,8 @@ lookupName hsc_env name = do
16711671
case res of
16721672
Util.Succeeded x -> return (Just x)
16731673
_ -> return Nothing
1674+
where
1675+
handle x = x `catch` \(_ :: IOEnvFailure) -> pure Nothing
16741676

16751677
pathToModuleName :: FilePath -> ModuleName
16761678
pathToModuleName = mkModuleName . map rep

ghcide/src/Development/IDE/Spans/Documentation.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ lookupKind env =
7979
fmap (fromRight Nothing) . catchSrcErrors (hsc_dflags env) "span" . lookupName env
8080

8181
getDocumentationTryGhc :: HscEnv -> Name -> IO SpanDoc
82-
getDocumentationTryGhc env n = fromMaybe emptySpanDoc . listToMaybe <$> getDocumentationsTryGhc env [n]
82+
getDocumentationTryGhc env n =
83+
(fromMaybe emptySpanDoc . listToMaybe <$> getDocumentationsTryGhc env [n])
84+
`catch` (\(_ :: IOEnvFailure) -> pure emptySpanDoc)
8385

8486
getDocumentationsTryGhc :: HscEnv -> [Name] -> IO [SpanDoc]
8587
getDocumentationsTryGhc env names = do

ghcide/test/exe/Main.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,7 +1983,7 @@ completionDocTests =
19831983
, "foo = ()"
19841984
, "bar = fo"
19851985
]
1986-
test doc (Position 3 8) "foo" Nothing ["*Defined at line 3, column 1 in this module*\n* * *\ndocdoc\n"]
1986+
test doc (Position 3 8) "foo" Nothing ["*Defined at line 3, column 1 in this module*\n* * *\n\n\ndocdoc\n"]
19871987
, testSession "local multi line doc with '\\n'" $ do
19881988
doc <- createDoc "A.hs" "haskell" $ T.unlines
19891989
[ "module A where"
@@ -1992,7 +1992,7 @@ completionDocTests =
19921992
, "foo = ()"
19931993
, "bar = fo"
19941994
]
1995-
test doc (Position 4 8) "foo" Nothing ["*Defined at line 4, column 1 in this module*\n* * *\n abcabc\n"]
1995+
test doc (Position 4 8) "foo" Nothing ["*Defined at line 4, column 1 in this module*\n* * *\n\n\nabcabc\n"]
19961996
, testSession "local multi line doc without '\\n'" $ do
19971997
doc <- createDoc "A.hs" "haskell" $ T.unlines
19981998
[ "module A where"
@@ -2002,7 +2002,7 @@ completionDocTests =
20022002
, "foo = ()"
20032003
, "bar = fo"
20042004
]
2005-
test doc (Position 5 8) "foo" Nothing ["*Defined at line 5, column 1 in this module*\n* * *\n abcabc\n\ndef\n"]
2005+
test doc (Position 5 8) "foo" Nothing ["*Defined at line 5, column 1 in this module*\n* * *\n\n\nabcabc \n\ndef\n"]
20062006
, testSession "extern empty doc" $ do
20072007
doc <- createDoc "A.hs" "haskell" $ T.unlines
20082008
[ "module A where"

0 commit comments

Comments
 (0)