on master help sign in
always show three lines of JSON in syntax error messages

Some specific errors benefit from having the line above, like in https://github.com/elm/error-message-catalog/issues/264 Since the JSON syntax errors are always for a single position (no context stack!) I figured I did a fix that just includes two extra lines for all JSON syntax errors. This should not be too disruptive and should give more of a feeling of place within the JSON file, especially when it's a single line with something weird on it!

commit63db0a11c0d89a9b5d641a82fe4cd358268c1058 authorEvan Czaplicki <evancz@users.noreply.github.com> dateThu 25 Jul 2019, 19:24 (7 years ago) parentadfbebf
1 file changed+6−2
compiler/src/Reporting/Error/Json.hs+6−2
compiler/src/Reporting/Error/Json.hs+6−2
@@ -51,9 +51,13 @@ parseErrorToReport :: FilePath -> Code.Source -> ParseError -> Reason -> Help.Re
5151parseErrorToReport path source parseError reason =
5252 let
5353 toSnippet title row col (problem, details) =
54− let pos = A.Position row col in
54+ let
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
5559 Help.jsonReport title (Just path) $
56− Code.toSnippet source (A.Region pos pos) Nothing
60+ Code.toSnippet source surroundings (Just region)
5761 ( D.reflow (because reason problem)
5862 , details
5963 )