File tree 1 file changed +9
-1
lines changed
ghcide/src/Development/IDE/Spans
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -318,7 +318,15 @@ nameToLocation hiedb lookupModule name = runMaybeT $
318
318
mod <- MaybeT $ return $ nameModule_maybe name
319
319
erow <- liftIO $ findDef hiedb (nameOccName name) (Just $ moduleName mod ) (Just $ moduleUnitId mod )
320
320
case erow of
321
- [] -> MaybeT $ pure Nothing
321
+ [] -> do
322
+ -- If the lookup failed, try again without specifying a unit-id.
323
+ -- This is a hack to make find definition work better with ghcide's nascent multi-component support,
324
+ -- where names from a component that has been indexed in a previous session but not loaded in this
325
+ -- session may end up with different unit ids
326
+ erow <- liftIO $ findDef hiedb (nameOccName name) (Just $ moduleName mod ) Nothing
327
+ case erow of
328
+ [] -> MaybeT $ pure Nothing
329
+ xs -> lift $ mapMaybeM (runMaybeT . defRowToLocation lookupModule) xs
322
330
xs -> lift $ mapMaybeM (runMaybeT . defRowToLocation lookupModule) xs
323
331
324
332
defRowToLocation :: Monad m => LookupModule m -> Res DefRow -> MaybeT m Location
You can’t perform that action at this time.
0 commit comments