Skip to content

Commit 830b3ee

Browse files
committed
Fix multiline eval padding
See #2907
1 parent 97a8909 commit 830b3ee

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

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

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,17 @@ import GHC (ClsInst,
7676
parseName, pprFamInst,
7777
pprInstance, setTargets,
7878
typeKind)
79-
#if MIN_VERSION_ghc(9,2,0)
80-
import GHC (Fixity)
81-
#endif
79+
80+
81+
8282
import qualified GHC.LanguageExtensions.Type as LangExt (Extension (..))
8383

8484
import Development.IDE.Core.FileStore (setSomethingModified)
8585
import Development.IDE.Types.Shake (toKey)
8686
import Ide.Plugin.Config (Config)
87-
#if MIN_VERSION_ghc(9,2,0)
88-
import GHC.Types.SrcLoc (UnhelpfulSpanReason (UnhelpfulInteractive))
89-
#endif
87+
88+
89+
9090
import Ide.Plugin.Eval.Code (Statement, asStatements,
9191
evalSetup, myExecStmt,
9292
propSetup, resultRange,
@@ -110,13 +110,13 @@ import Language.LSP.Types hiding
110110
import Language.LSP.Types.Lens (end, line)
111111
import Language.LSP.VFS (virtualFileText)
112112

113-
#if MIN_VERSION_ghc(9,2,0)
114-
#elif MIN_VERSION_ghc(9,0,0)
115-
import GHC.Driver.Session (unitDatabases, unitState)
116-
import GHC.Types.SrcLoc (UnhelpfulSpanReason (UnhelpfulInteractive))
117-
#else
113+
114+
115+
116+
117+
118118
import DynFlags
119-
#endif
119+
120120

121121

122122
{- | Code Lens provider
@@ -251,15 +251,15 @@ runEvalCmd plId st EvalParams{..} =
251251
. flip xopt_unset LangExt.MonomorphismRestriction
252252
$ idflags
253253
setInteractiveDynFlags $ df'
254-
#if MIN_VERSION_ghc(9,0,0)
255-
{
256-
packageFlags =
257-
packageFlags
258-
df
259-
, useColor = Never
260-
, canUseColor = False
261-
}
262-
#else
254+
255+
256+
257+
258+
259+
260+
261+
262+
263263
{ pkgState =
264264
pkgState
265265
df
@@ -272,7 +272,7 @@ runEvalCmd plId st EvalParams{..} =
272272
, useColor = Never
273273
, canUseColor = False
274274
}
275-
#endif
275+
276276

277277
-- Load the module with its current content (as the saved module might not be up to date)
278278
-- BUG: this fails for files that requires preprocessors (e.g. CPP) for ghc < 8.8
@@ -358,8 +358,9 @@ runTests EvalConfig{..} e@(_st, _) tests = do
358358
dbg "TEST RESULTS" rs
359359

360360
let checkedResult = testCheck eval_cfg_diff (section, test) rs
361+
let resultLines = concatMap T.lines checkedResult
361362

362-
let edit = asEdit (sectionFormat section) test (map pad checkedResult)
363+
let edit = asEdit (sectionFormat section) test (map pad resultLines)
363364
dbg "TEST EDIT" edit
364365
return edit
365366

@@ -511,11 +512,11 @@ evals mark_exception (st, fp) df stmts = do
511512
void $ runDecls stmt
512513
return Nothing
513514
pf = initParserOpts df
514-
#if !MIN_VERSION_ghc(9,0,0)
515+
515516
unhelpfulReason = "<interactive>"
516-
#else
517-
unhelpfulReason = UnhelpfulInteractive
518-
#endif
517+
518+
519+
519520
exec stmt l =
520521
let opts = execOptions{execSourceFile = fp, execLineNumber = l}
521522
in myExecStmt stmt opts
@@ -690,9 +691,9 @@ doTypeCmd dflags arg = do
690691

691692
parseExprMode :: Text -> (TcRnExprMode, T.Text)
692693
parseExprMode rawArg = case T.break isSpace rawArg of
693-
#if !MIN_VERSION_ghc(9,2,0)
694+
694695
("+v", rest) -> (TM_NoInst, T.strip rest)
695-
#endif
696+
696697
("+d", rest) -> (TM_Default, T.strip rest)
697698
_ -> (TM_Inst, rawArg)
698699

0 commit comments

Comments
 (0)