diff --git a/ghcide/bench/lib/Experiments.hs b/ghcide/bench/lib/Experiments.hs index 7b3ffbb642..562e870a61 100644 --- a/ghcide/bench/lib/Experiments.hs +++ b/ghcide/bench/lib/Experiments.hs @@ -156,10 +156,10 @@ experiments = forM_ identifierP $ \p -> changeDoc doc [charEdit p] ) ( \docs -> do - Just hieYaml <- uriToFilePath <$> getDocUri "hie.yaml" - liftIO $ appendFile hieYaml "##\n" + hieYamlUri <- getDocUri "hie.yaml" + liftIO $ appendFile (fromJust $ uriToFilePath hieYamlUri) "##\n" sendNotification SWorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $ - List [ FileEvent (filePathToUri "hie.yaml") FcChanged ] + List [ FileEvent hieYamlUri FcChanged ] forM_ docs $ \DocumentPositions{..} -> changeDoc doc [charEdit stringLiteralP] waitForProgressDone @@ -171,10 +171,10 @@ experiments = bench "hover after cradle edit" (\docs -> do - Just hieYaml <- uriToFilePath <$> getDocUri "hie.yaml" - liftIO $ appendFile hieYaml "##\n" + hieYamlUri <- getDocUri "hie.yaml" + liftIO $ appendFile (fromJust $ uriToFilePath hieYamlUri) "##\n" sendNotification SWorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $ - List [ FileEvent (filePathToUri "hie.yaml") FcChanged ] + List [ FileEvent hieYamlUri FcChanged ] flip allWithIdentifierPos docs $ \DocumentPositions{..} -> isJust <$> getHover doc (fromJust identifierP) ), --------------------------------------------------------------------------------------- diff --git a/ghcide/src/Development/IDE/Core/Rules.hs b/ghcide/src/Development/IDE/Core/Rules.hs index c4cbab0d02..0d4c082931 100644 --- a/ghcide/src/Development/IDE/Core/Rules.hs +++ b/ghcide/src/Development/IDE/Core/Rules.hs @@ -138,7 +138,7 @@ import qualified Language.LSP.Server as LSP import Language.LSP.Types (SMethod (SCustomMethod)) import Language.LSP.VFS import Module -import System.Directory (canonicalizePath) +import System.Directory (canonicalizePath, makeAbsolute) import TcRnMonad (tcg_dependent_files) import Control.Applicative @@ -674,9 +674,12 @@ loadGhcSession = do -- add the deps to the Shake graph let addDependency fp = do - let nfp = toNormalizedFilePath' fp + -- VSCode uses absolute paths in its filewatch notifications + afp <- liftIO $ makeAbsolute fp + let nfp = toNormalizedFilePath' afp itExists <- getFileExists nfp - when itExists $ void $ use_ GetModificationTime nfp + when itExists $ void $ do + use_ GetModificationTime nfp mapM_ addDependency deps opts <- getIdeOptions