From ee1c4ffe15d2cb116a66c09d13d4a13f20d63f2a Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Thu, 19 Apr 2007 14:40:05 +0000 Subject: [PATCH] fix padding calculation in listAround --- compiler/ghci/InteractiveUI.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 -- 1.7.10.4