diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index af1dacb531..2ce995af44 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -135,6 +135,7 @@ jobs: - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} name: untar run: | + mkdir -p ~/.cabal tar xzf workspace.tar.gz tar xzf cabal.tar.gz --directory ~/.cabal diff --git a/ghcide/ghcide.cabal b/ghcide/ghcide.cabal index 326081e3c9..bd33f46841 100644 --- a/ghcide/ghcide.cabal +++ b/ghcide/ghcide.cabal @@ -2,7 +2,7 @@ cabal-version: 2.4 build-type: Simple category: Development name: ghcide -version: 1.4.0.0 +version: 1.4.0.1 license: Apache-2.0 license-file: LICENSE author: Digital Asset and Ghcide contributors diff --git a/ghcide/src/Development/IDE/Spans/AtPoint.hs b/ghcide/src/Development/IDE/Spans/AtPoint.hs index a6c8d7038c..3cbec0f363 100644 --- a/ghcide/src/Development/IDE/Spans/AtPoint.hs +++ b/ghcide/src/Development/IDE/Spans/AtPoint.hs @@ -57,6 +57,7 @@ import Data.List (isSuffixOf) import Data.List.Extra (dropEnd1, nubOrd) import HieDb hiding (pointCommand) +import System.Directory (doesFileExist) -- | Gives a Uri for the module, given the .hie file location and the the module info -- The Bool denotes if it is a boot module @@ -312,8 +313,19 @@ nameToLocation hiedb lookupModule name = runMaybeT $ case nameSrcSpan name of sp@(OldRealSrcSpan rsp) -- Lookup in the db if we got a location in a boot file - | not $ "boot" `isSuffixOf` unpackFS (srcSpanFile rsp) -> MaybeT $ pure $ fmap pure $ srcSpanToLocation sp - sp -> do + | fs <- unpackFS (srcSpanFile rsp) + , not $ "boot" `isSuffixOf` fs + -> do + itExists <- liftIO $ doesFileExist fs + if itExists + then MaybeT $ pure $ fmap pure $ srcSpanToLocation sp + -- When reusing .hie files from a cloud cache, + -- the paths may not match the local file system. + -- Let's fall back to the hiedb in case it contains local paths + else fallbackToDb sp + sp -> fallbackToDb sp + where + fallbackToDb sp = do guard (sp /= wiredInSrcSpan) -- This case usually arises when the definition is in an external package. -- In this case the interface files contain garbage source spans