on master help sign in
always show three lines of JSON in syntax error messages
63db0a1Evan Czaplicki
compiler/src/Reporting/Error/Json.hs+6−2
@@ -51,9 +51,13 @@ parseErrorToReport :: FilePath -> Code.Source -> ParseError -> Reason -> Help.Re
51parseErrorToReport path source parseError reason =
51parseErrorToReport path source parseError reason =
52 let
52 let
53 toSnippet title row col (problem, details) =
53 toSnippet title row col (problem, details) =
54+ let
54− let pos = A.Position row col in
55+ pos = A.Position row col
56+ surroundings = A.Region (A.Position (max 1 (row - 2)) 1) pos
57+ region = A.Region pos pos
58+ in
55 Help.jsonReport title (Just path) $
59 Help.jsonReport title (Just path) $
56− Code.toSnippet source (A.Region pos pos) Nothing
60+ Code.toSnippet source surroundings (Just region)
57 ( D.reflow (because reason problem)
61 ( D.reflow (because reason problem)
58 , details
62 , details
59 )
63 )