Skip to content

Commit b86b98d

Browse files
committed
Fix eval plugin
1 parent 7ab7b45 commit b86b98d

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

Diff for: plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs

+3-5
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ import Ide.Plugin.Eval.Config (EvalConfig (..),
116116
import Ide.Plugin.Eval.GHC (addImport,
117117
addPackages,
118118
hasPackage,
119-
showDynFlags)
119+
showDynFlags,
120+
setSessionAndInteractiveDynFlags)
120121
import Ide.Plugin.Eval.Parse.Comments (commentsToSections)
121122
import Ide.Plugin.Eval.Parse.Option (parseSetFlags)
122123
import Ide.Plugin.Eval.Rules (queueForEvaluation,
@@ -465,9 +466,7 @@ evals mark_exception (st, fp) df stmts = do
465466
<> T.pack (intercalate ", " $ map SrcLoc.unLoc ignoreds)
466467
]
467468
dbg "post set" $ showDynFlags df'
468-
_ <- setSessionDynFlags df'
469-
sessDyns <- getSessionDynFlags
470-
setInteractiveDynFlags sessDyns
469+
setSessionAndInteractiveDynFlags df'
471470
pure $ warnings <> igns
472471
| -- A type/kind command
473472
Just (cmd, arg) <- parseGhciLikeCmd $ T.pack stmt =
@@ -689,4 +688,3 @@ parseGhciLikeCmd :: Text -> Maybe (Text, Text)
689688
parseGhciLikeCmd input = do
690689
(':', rest) <- T.uncons $ T.stripStart input
691690
pure $ second T.strip $ T.break isSpace rest
692-

Diff for: plugins/hls-eval-plugin/src/Ide/Plugin/Eval/GHC.hs

+21
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE LambdaCase #-}
23
{-# LANGUAGE ScopedTypeVariables #-}
34
{-# LANGUAGE StandaloneDeriving #-}
@@ -11,6 +12,7 @@ module Ide.Plugin.Eval.GHC (
1112
addPackages,
1213
modifyFlags,
1314
showDynFlags,
15+
setSessionAndInteractiveDynFlags,
1416
) where
1517

1618
import Data.List (isPrefixOf)
@@ -25,6 +27,12 @@ import Development.IDE.GHC.Util (printOutputable)
2527
import GHC.LanguageExtensions.Type (Extension (..))
2628
import Ide.Plugin.Eval.Util (gStrictTry)
2729

30+
#if MIN_VERSION_ghc(9,3,0)
31+
import GHC (setUnitDynFlags, setTopSessionDynFlags)
32+
import GHC.Driver.Session (getDynFlags)
33+
import GHC.Driver.Env
34+
#endif
35+
2836
{- $setup
2937
>>> import GHC
3038
>>> import GHC.Paths
@@ -164,3 +172,16 @@ showDynFlags df =
164172

165173
vList :: [String] -> SDoc
166174
vList = vcat . map text
175+
176+
setSessionAndInteractiveDynFlags :: DynFlags -> Ghc ()
177+
setSessionAndInteractiveDynFlags df = do
178+
#if MIN_VERSION_ghc(9,3,0)
179+
_ <- setUnitDynFlags (homeUnitId_ df) df
180+
modifySession (hscUpdateLoggerFlags . hscSetActiveUnitId (homeUnitId_ df))
181+
df' <- getDynFlags
182+
setTopSessionDynFlags df'
183+
#else
184+
_ <- setSessionDynFlags df
185+
#endif
186+
sessDyns <- getSessionDynFlags
187+
setInteractiveDynFlags sessDyns

0 commit comments

Comments
 (0)