From 48237d69374dd405cbce78ea8d20841c29efab48 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sun, 24 Oct 2021 11:06:02 +0100 Subject: [PATCH 1/2] fix defaultIdeOptions It should use the default config settings for checkProject and checkParents --- ghcide/src/Development/IDE/Main.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ghcide/src/Development/IDE/Main.hs b/ghcide/src/Development/IDE/Main.hs index 1663a52f38..5f1defb027 100644 --- a/ghcide/src/Development/IDE/Main.hs +++ b/ghcide/src/Development/IDE/Main.hs @@ -86,7 +86,8 @@ import GHC.IO.Handle (hDuplicate) import HIE.Bios.Cradle (findCradle) import qualified HieDb.Run as HieDb import Ide.Plugin.Config (CheckParents (NeverCheck), - Config, + Config, checkParents, + checkProject, getConfigFromNotification) import Ide.Plugin.ConfigUtils (pluginsToDefaultConfig, pluginsToVSCodeExtensionSchema) @@ -193,7 +194,10 @@ defaultArguments priority = Arguments , argsGhcidePlugin = mempty , argsHlsPlugins = pluginDescToIdePlugins Ghcide.descriptors , argsSessionLoadingOptions = def - , argsIdeOptions = const defaultIdeOptions + , argsIdeOptions = \config ghcSession -> (defaultIdeOptions ghcSession) + { optCheckProject = pure $ checkProject config + , optCheckParents = pure $ checkParents config + } , argsLspOptions = def {LSP.completionTriggerCharacters = Just "."} , argsDefaultHlsConfig = def , argsGetHieDbLoc = getHieDbLoc From 2c6b9370cadadc5d5adb8e3bc25773687b513de1 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Mon, 25 Oct 2021 09:21:30 +0100 Subject: [PATCH 2/2] duplicate the DynLinker to avoid interference --- .../hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs index 41dea1bd48..30c2284e6f 100644 --- a/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs +++ b/plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs @@ -113,7 +113,10 @@ import UnliftIO.Temporary (withSystemTempFile) import GHC.Driver.Session (unitDatabases, unitState) import GHC.Types.SrcLoc (UnhelpfulSpanReason (UnhelpfulInteractive)) #else +import Control.Concurrent.MVar import DynFlags +import HscTypes (HscEnv (hsc_dynLinker)) +import LinkerTypes (DynLinker (..)) #endif @@ -556,7 +559,14 @@ runGetSession st nfp = liftIO $ runAction "eval" st $ do let fp = fromNormalizedFilePath nfp ((_, res),_) <- liftIO $ loadSessionFun fp let hscEnv = fromMaybe (error $ "Unknown file: " <> fp) res - ghcSessionDepsDefinition hscEnv nfp + hscEnvWithDeps <- ghcSessionDepsDefinition hscEnv nfp + -- duplicate the linker since it is mutable and therefore not multi-threaded + duplicateDynLinker hscEnvWithDeps + +duplicateDynLinker :: MonadIO m => HscEnv -> m HscEnv +duplicateDynLinker hsc = do + newLinker <- liftIO $ newMVar =<< readMVar (dl_mpls $ hsc_dynLinker hsc) + return hsc{ hsc_dynLinker = DynLinker newLinker} needsQuickCheck :: [(Section, Test)] -> Bool needsQuickCheck = any (isProperty . snd)