Commit 07b65816 authored by Fredrik Wieczerkowski's avatar Fredrik Wieczerkowski

Highlight span preview from min to max column

...instead of from the start to the end column, since those may no
longer be in order in multi-line spans.

This change thus fixes the previews for multi-line spans.
parent 5dd5180a
......@@ -90,14 +90,15 @@ ppSpanPreview (Span f (Position _ sl sc) (Position _ el ec))
lnNumsRaw = (\i -> if (i - sl) `mod` lnInterval == 0 then show i else "") <$> [sl..el]
lnNums = text <$> lPadStr lnNumWidth <$> (vPad ++ lnNumsRaw ++ vPad)
gutter = text <$> replicate (lnCount + 2 * vPadCount) "|"
-- TODO: This span highlight currently does not take multi-line spans into account
highlight = replicate (sc - 1) ' ' ++ replicate (1 + ec - sc) '^'
highlight = replicate (minC - 1) ' ' ++ replicate (1 + maxC - minC) '^'
previews = text <$> (vPad ++ lnContents ++ [highlight] ++ replicate (vPadCount - 1) "")
return $ vcat $ map hsep $ transpose [lnNums, gutter, previews]
where vPadCount = 1 -- Number of padding lines at the top and bottom
lnInterval = 1 -- Number of lines between displayed line numbers
lnCount = 1 + el - sl
minC = min sc ec
maxC = max sc ec
numWidth n = 1 + floor (logBase 10 $ (fromIntegral n) :: Double)
lnNumWidth = 1 + numWidth el
vPad = replicate 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