Skip to content

Commit 39a6e25

Browse files
author
DeviousStoat
committed
Avoid creating an empty section if no instances are found
1 parent e80d081 commit 39a6e25

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,10 @@ atPoint IdeOptions{} (HAR _ hf _ _ (kind :: HieKind hietype)) (DKMap dm km) env
318318
instancesForName :: IO (Maybe [ClsInst])
319319
instancesForName = runMaybeT $ do
320320
typ <- MaybeT . pure $ lookupNameEnv km n >>= tyThingAsDataType
321-
liftIO $ evalGhcEnv env $ getInstancesForType typ
321+
clsInst <- liftIO $ evalGhcEnv env $ getInstancesForType typ
322+
-- Avoid creating an empty wrapped section if no instances are found
323+
guard $ not $ null clsInst
324+
return clsInst
322325

323326
-- | Gets the datatype `Type` corresponding to a TyThing, if it repressents a datatype or
324327
-- a data constructor.

0 commit comments

Comments
 (0)