Skip to content

Commit

Permalink
Fix multiline eval padding
Browse files Browse the repository at this point in the history
  • Loading branch information
xsebek committed May 16, 2022
1 parent 97a8909 commit 830b3ee
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ import GHC (ClsInst,
parseName, pprFamInst,
pprInstance, setTargets,
typeKind)
#if MIN_VERSION_ghc(9,2,0)
import GHC (Fixity)
#endif



import qualified GHC.LanguageExtensions.Type as LangExt (Extension (..))

import Development.IDE.Core.FileStore (setSomethingModified)
import Development.IDE.Types.Shake (toKey)
import Ide.Plugin.Config (Config)
#if MIN_VERSION_ghc(9,2,0)
import GHC.Types.SrcLoc (UnhelpfulSpanReason (UnhelpfulInteractive))
#endif



import Ide.Plugin.Eval.Code (Statement, asStatements,
evalSetup, myExecStmt,
propSetup, resultRange,
Expand All @@ -110,13 +110,13 @@ import Language.LSP.Types hiding
import Language.LSP.Types.Lens (end, line)
import Language.LSP.VFS (virtualFileText)

#if MIN_VERSION_ghc(9,2,0)
#elif MIN_VERSION_ghc(9,0,0)
import GHC.Driver.Session (unitDatabases, unitState)
import GHC.Types.SrcLoc (UnhelpfulSpanReason (UnhelpfulInteractive))
#else





import DynFlags
#endif



{- | Code Lens provider
Expand Down Expand Up @@ -251,15 +251,15 @@ runEvalCmd plId st EvalParams{..} =
. flip xopt_unset LangExt.MonomorphismRestriction
$ idflags
setInteractiveDynFlags $ df'
#if MIN_VERSION_ghc(9,0,0)
{
packageFlags =
packageFlags
df
, useColor = Never
, canUseColor = False
}
#else









{ pkgState =
pkgState
df
Expand All @@ -272,7 +272,7 @@ runEvalCmd plId st EvalParams{..} =
, useColor = Never
, canUseColor = False
}
#endif


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

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

let edit = asEdit (sectionFormat section) test (map pad checkedResult)
let edit = asEdit (sectionFormat section) test (map pad resultLines)
dbg "TEST EDIT" edit
return edit

Expand Down Expand Up @@ -511,11 +512,11 @@ evals mark_exception (st, fp) df stmts = do
void $ runDecls stmt
return Nothing
pf = initParserOpts df
#if !MIN_VERSION_ghc(9,0,0)

unhelpfulReason = "<interactive>"
#else
unhelpfulReason = UnhelpfulInteractive
#endif



exec stmt l =
let opts = execOptions{execSourceFile = fp, execLineNumber = l}
in myExecStmt stmt opts
Expand Down Expand Up @@ -690,9 +691,9 @@ doTypeCmd dflags arg = do

parseExprMode :: Text -> (TcRnExprMode, T.Text)
parseExprMode rawArg = case T.break isSpace rawArg of
#if !MIN_VERSION_ghc(9,2,0)

("+v", rest) -> (TM_NoInst, T.strip rest)
#endif

("+d", rest) -> (TM_Default, T.strip rest)
_ -> (TM_Inst, rawArg)

Expand Down

0 comments on commit 830b3ee

Please sign in to comment.