diff --git a/ghcide/src/Development/IDE/GHC/Compat/Outputable.hs b/ghcide/src/Development/IDE/GHC/Compat/Outputable.hs index 57f3cc368c..f1ace4693b 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Outputable.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Outputable.hs @@ -13,6 +13,8 @@ module Development.IDE.GHC.Compat.Outputable ( mkPrintUnqualified, mkPrintUnqualifiedDefault, PrintUnqualified(..), + defaultUserStyle, + withPprStyle, -- * Parser errors PsWarning, PsError, @@ -43,7 +45,8 @@ import GHC.Types.SourceError import GHC.Types.SrcLoc import GHC.Unit.State import GHC.Utils.Error hiding (mkWarnMsg) -import GHC.Utils.Outputable +import GHC.Utils.Outputable as Out hiding (defaultUserStyle) +import qualified GHC.Utils.Outputable as Out import GHC.Utils.Panic #elif MIN_VERSION_ghc(9,0,0) import GHC.Driver.Session @@ -52,14 +55,16 @@ import GHC.Types.Name.Reader (GlobalRdrEnv) import GHC.Types.SrcLoc import GHC.Utils.Error as Err hiding (mkWarnMsg) import qualified GHC.Utils.Error as Err -import GHC.Utils.Outputable as Out +import GHC.Utils.Outputable as Out hiding (defaultUserStyle) +import qualified GHC.Utils.Outputable as Out #else import Development.IDE.GHC.Compat.Core (GlobalRdrEnv) import DynFlags import ErrUtils hiding (mkWarnMsg) import qualified ErrUtils as Err import HscTypes -import Outputable as Out +import Outputable as Out hiding (defaultUserStyle) +import qualified Outputable as Out import SrcLoc #endif @@ -178,3 +183,10 @@ mkWarnMsg = #else Err.mkWarnMsg #endif + +defaultUserStyle :: PprStyle +#if MIN_VERSION_ghc(9,0,0) +defaultUserStyle = Out.defaultUserStyle +#else +defaultUserStyle = Out.defaultUserStyle unsafeGlobalDynFlags +#endif diff --git a/ghcide/src/Development/IDE/Spans/Common.hs b/ghcide/src/Development/IDE/Spans/Common.hs index 0a60120138..54ee952f49 100644 --- a/ghcide/src/Development/IDE/Spans/Common.hs +++ b/ghcide/src/Development/IDE/Spans/Common.hs @@ -35,7 +35,7 @@ type DocMap = NameEnv SpanDoc type KindMap = NameEnv TyThing showGhc :: Outputable a => a -> T.Text -showGhc = showSD . ppr +showGhc = showSD . withPprStyle defaultUserStyle . ppr showSD :: SDoc -> T.Text showSD = T.pack . unsafePrintSDoc @@ -62,7 +62,7 @@ safeTyThingId _ = Nothing -- Possible documentation for an element in the code data SpanDoc = SpanDocString HsDocString SpanDocUris - | SpanDocText [T.Text] SpanDocUris + | SpanDocText [T.Text] SpanDocUris deriving stock (Eq, Show, Generic) deriving anyclass NFData diff --git a/ghcide/test/exe/Main.hs b/ghcide/test/exe/Main.hs index 96ad20c9df..754a0915c9 100644 --- a/ghcide/test/exe/Main.hs +++ b/ghcide/test/exe/Main.hs @@ -4288,11 +4288,7 @@ findDefinitionAndHoverTests = let , test no yes outL45 outSig "top-level signature #767" , test broken broken innL48 innSig "inner signature #767" , test no yes holeL60 hleInfo "hole without internal name #831" - , if ghcVersion >= GHC92 then - -- Broken on GHC 9.2 and above due to printing of uniques - test no yes holeL65 [] "hole with variable" - else - test no yes holeL65 hleInfo2 "hole with variable" + , test no yes holeL65 hleInfo2 "hole with variable" , test no skip cccL17 docLink "Haddock html links" , testM yes yes imported importedSig "Imported symbol" , testM yes yes reexported reexportedSig "Imported symbol (reexported)"