From: Simon Marlow Date: Thu, 19 Apr 2007 14:40:05 +0000 (+0000) Subject: fix padding calculation in listAround X-Git-Tag: 2007-05-06~147 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=ee1c4ffe15d2cb116a66c09d13d4a13f20d63f2a fix padding calculation in listAround --- diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs index 3713c4c..7442ad4 100644 --- a/compiler/ghci/InteractiveUI.hs +++ b/compiler/ghci/InteractiveUI.hs @@ -1659,9 +1659,9 @@ listAround span do_highlight = do contents <- BS.readFile (unpackFS file) let lines = BS.split '\n' contents - these_lines = take (line2 - line1 + 1 + 2*padding) $ - drop (line1 - 1 - padding) $ lines - fst_line = max 1 (line1 - padding) + these_lines = take (line2 - line1 + 1 + pad_before + pad_after) $ + drop (line1 - 1 - pad_before) $ lines + fst_line = max 1 (line1 - pad_before) line_nos = [ fst_line .. ] highlighted | do_highlight = zipWith highlight line_nos these_lines @@ -1677,7 +1677,10 @@ listAround span do_highlight = do col1 = srcSpanStartCol span line2 = srcSpanEndLine span col2 = srcSpanEndCol span - padding = 1 + + pad_before | line1 == 1 = 0 + | otherwise = 1 + pad_after = 1 highlight no line | no == line1 && no == line2