Skip to content

Commit a1ead72

Browse files
authored
Fix multiline eval plugin padding (#2910)
* Test multiline eval results - add test for multiline show instance See #2907 * Fix multiline eval padding See #2907
1 parent b1bf549 commit a1ead72

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -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

plugins/hls-eval-plugin/test/Main.hs

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ tests =
6868
, goldenWithEval "Refresh an evaluation" "T5" "hs"
6969
, goldenWithEval "Refresh an evaluation w/ lets" "T6" "hs"
7070
, goldenWithEval "Refresh a multiline evaluation" "T7" "hs"
71+
, goldenWithEval "Evaluate a multi-line show result" "TMultiResult" "hs" -- Do not escape from comments!
7172
, testCase "Semantic and Lexical errors are reported" $ do
7273
evalInFile "T8.hs" "-- >>> noFunctionWithThisName" "-- Variable not in scope: noFunctionWithThisName"
7374
evalInFile "T8.hs" "-- >>> res = \"a\" + \"bc\"" $
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module TMultiResult where
2+
-- test multiline show instance (see #2907)
3+
4+
data Multiline = M {l1 :: String, l2 :: String} deriving Read
5+
6+
instance Show Multiline where
7+
show m = "M {\n l1=" <> show (l1 m) <> ",\n l2=" <> show (l2 m) <> "\n}"
8+
9+
-- >>> M "first line" "second line"
10+
-- M {
11+
-- l1="first line",
12+
-- l2="second line"
13+
-- }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module TMultiResult where
2+
-- test multiline show instance (see #2907)
3+
4+
data Multiline = M {l1 :: String, l2 :: String} deriving Read
5+
6+
instance Show Multiline where
7+
show m = "M {\n l1=" <> show (l1 m) <> ",\n l2=" <> show (l2 m) <> "\n}"
8+
9+
-- >>> M "first line" "second line"

0 commit comments

Comments
 (0)