diff --git a/ghcide/src/Development/IDE/Import/FindImports.hs b/ghcide/src/Development/IDE/Import/FindImports.hs index 6140199772..3e3fc4d942 100644 --- a/ghcide/src/Development/IDE/Import/FindImports.hs +++ b/ghcide/src/Development/IDE/Import/FindImports.hs @@ -131,13 +131,17 @@ locateModule -> m (Either [FileDiagnostic] Import) locateModule env comp_info exts targetFor modName mbPkgName isSource = do case mbPkgName of - -- "this" means that we should only look in the current package #if MIN_VERSION_ghc(9,3,0) - ThisPkg _ -> do + -- 'ThisPkg' just means some home module, not the current unit + ThisPkg uid + | Just (dirs, reexports) <- lookup uid import_paths + -> lookupLocal uid dirs reexports + | otherwise -> return $ Left $ notFoundErr env modName $ LookupNotFound [] #else + -- "this" means that we should only look in the current package Just "this" -> do -#endif lookupLocal (homeUnitId_ dflags) (importPaths dflags) S.empty +#endif -- if a package name is given we only go look for a package #if MIN_VERSION_ghc(9,3,0) OtherPkg uid diff --git a/ghcide/test/data/multi-unit/b-1.0.0-inplace b/ghcide/test/data/multi-unit/b-1.0.0-inplace index b08c50c1ce..fe43e3a92d 100644 --- a/ghcide/test/data/multi-unit/b-1.0.0-inplace +++ b/ghcide/test/data/multi-unit/b-1.0.0-inplace @@ -16,4 +16,5 @@ a-1.0.0-inplace -package base -XHaskell98 +-XPackageImports B diff --git a/ghcide/test/data/multi-unit/b/B.hs b/ghcide/test/data/multi-unit/b/B.hs index 2c6d4b28a2..54c6b874fc 100644 --- a/ghcide/test/data/multi-unit/b/B.hs +++ b/ghcide/test/data/multi-unit/b/B.hs @@ -1,3 +1,3 @@ module B(module B) where -import A +import "a" A qux = foo