diff --git a/ghcide b/ghcide index 0bfce3114c..c1678223bb 160000 --- a/ghcide +++ b/ghcide @@ -1 +1 @@ -Subproject commit 0bfce3114c28bd00f7bf5729c32ec0f23a8d8854 +Subproject commit c1678223bbe9ec73628888ef466e0e471258040c diff --git a/plugins/default/src/Ide/Plugin/Eval.hs b/plugins/default/src/Ide/Plugin/Eval.hs index f59650b0f6..cad3c0b588 100644 --- a/plugins/default/src/Ide/Plugin/Eval.hs +++ b/plugins/default/src/Ide/Plugin/Eval.hs @@ -35,13 +35,14 @@ import Data.Bifunctor (Bifunctor (first)) import Data.Char (isSpace) import qualified Data.HashMap.Strict as Map import Data.List (find) -import Data.Maybe (catMaybes) +import Data.Maybe (fromMaybe, catMaybes) import Data.String (IsString (fromString)) import Data.Text (Text) import qualified Data.Text as T import Data.Time (getCurrentTime) import Development.IDE -import Development.IDE.GHC.Compat (DynFlags, ExecResult (..), GeneralFlag (Opt_IgnoreHpcChanges, Opt_IgnoreOptimChanges, Opt_ImplicitImportQualified), +import Development.IDE.GHC.Compat (DynFlags(importPaths), ExecResult (..), + GeneralFlag (Opt_IgnoreHpcChanges, Opt_IgnoreOptimChanges, Opt_ImplicitImportQualified), Ghc, GhcLink (LinkInMemory), GhcMode (CompManager), HscTarget (HscInterpreted), @@ -61,10 +62,9 @@ import Development.IDE.GHC.Compat (DynFlags, ExecResult (..), GeneralF setTargets, simpleImportDecl, typeKind, ways) import DynamicLoading (initializePlugins) -import DynFlags (targetPlatform) import GHC.Generics (Generic) import GhcMonad (modifySession) -import GhcPlugins (defaultLogActionHPutStrDoc, +import GhcPlugins (targetPlatform, defaultLogActionHPutStrDoc, gopt_set, gopt_unset, interpWays, updateWays, wayGeneralFlags, wayUnsetGeneralFlags) @@ -195,7 +195,11 @@ runEvalCmd lsp state EvalParams {..} = withIndefiniteProgress lsp "Eval" Cancell hscEnv' <- ExceptT $ evalGhcEnv (hscEnv session) $ do env <- getSession + -- Install the module pragmas and options df <- liftIO $ setupDynFlagsForGHCiLike env $ ms_hspp_opts ms + -- Restore the cradle import paths + df <- return df{importPaths = fromMaybe (importPaths df) $ envImportPaths session} + -- Set the modified flags in the session _lp <- setSessionDynFlags df -- copy the package state to the interactive DynFlags @@ -295,7 +299,7 @@ evalGhciLikeCmd cmd arg = do df <- getSessionDynFlags case lookup cmd ghciLikeCommands <|> snd <$> find (T.isPrefixOf cmd . fst) ghciLikeCommands of - Just hndler -> + Just hndler -> fmap (T.unlines . map ("-- " <>) . T.lines ) diff --git a/test/functional/Eval.hs b/test/functional/Eval.hs index a196ee0485..d9b36ca919 100644 --- a/test/functional/Eval.hs +++ b/test/functional/Eval.hs @@ -88,6 +88,8 @@ tests = testGroup $ goldenTest "T24.hs" , testCase ":kind treats a multilined result properly" $ goldenTest "T25.hs" + , testCase "local imports" + $ goldenTest "T26.hs" ] goldenTest :: FilePath -> IO () diff --git a/test/testdata/eval/T26.hs b/test/testdata/eval/T26.hs new file mode 100644 index 0000000000..424cdf12c5 --- /dev/null +++ b/test/testdata/eval/T26.hs @@ -0,0 +1,4 @@ +module T26 where +import T25 () + +-- >>> "hello" diff --git a/test/testdata/eval/T26.hs.expected b/test/testdata/eval/T26.hs.expected new file mode 100644 index 0000000000..bf9ebacc5a --- /dev/null +++ b/test/testdata/eval/T26.hs.expected @@ -0,0 +1,5 @@ +module T26 where +import T25 () + +-- >>> "hello" +-- "hello" diff --git a/test/testdata/eval/hie.yaml b/test/testdata/eval/hie.yaml index a2e9ed5148..66e96b9b28 100644 --- a/test/testdata/eval/hie.yaml +++ b/test/testdata/eval/hie.yaml @@ -1 +1,29 @@ -cradle: {direct: {arguments: ["T1", "T2", "T3", "T4"]}} +cradle: + direct: + arguments: + - "T1" + - "T2" + - "T3" + - "T4" + - "T5" + - "T6" + - "T7" + - "T8" + - "T9" + - "T10" + - "T11" + - "T12" + - "T13" + - "T14" + - "T15" + - "T16" + - "T17" + - "T18" + - "T19" + - "T20" + - "T21" + - "T22" + - "T23" + - "T24" + - "T25" + - "T26"