Commit bd6992b8 authored by Finn Teegen's avatar Finn Teegen
Browse files

Merge branch 'fix-span-preview' into 'master'

Handle out-of-bounds lines in span previews

Closes #113

See merge request !42
parents 1b630439 ae024ee3
......@@ -87,7 +87,9 @@ ppSpanPreview (Span f (Position _ sl sc) (Position _ el ec))
| otherwise = do
fileContents <- readFile f
let lnContent = lines fileContents !! (sl - 1)
let lns = lines fileContents
lnContent | sl <= 0 || sl > length lns = ""
| otherwise = lns !! (sl - 1)
lnNum = text <$> lPadStr lnNumWidth <$> (vPad ++ [show sl] ++ vPad)
ec' = if isMultiline then length lnContent else ec
gutter = text <$> replicate (1 + 2 * vPadCount) "|"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment