fix: errors: assertions: fix excerpt highlighting
This commit is contained in:
parent
d07bf4afbb
commit
41234f0e10
@ -615,11 +615,8 @@ checkBalanceAssertionOneCommodityB p@Posting{paccount=assertedacct} assertedamt
|
|||||||
where
|
where
|
||||||
finderrcols p t trendered = Just (col, Just col2)
|
finderrcols p t trendered = Just (col, Just col2)
|
||||||
where
|
where
|
||||||
-- col = unPos $ sourceColumn pos
|
-- Analyse the rendering to find the columns to highlight.
|
||||||
-- col2 = col + (length $ wbUnpack $ showBalanceAssertion ass)
|
tlines = dbg5 "tlines" $ max 1 $ length $ T.lines $ tcomment t -- transaction comment can generate extra lines
|
||||||
-- The saved parse position may not correspond to the rendering in the error message.
|
|
||||||
-- Instead, we analyse the rendering to find the columns:
|
|
||||||
tlines = length $ T.lines $ tcomment t -- transaction comment can generate extra lines
|
|
||||||
(col, col2) =
|
(col, col2) =
|
||||||
let def = (5, maximum (map T.length $ T.lines trendered)) -- fallback: underline whole posting. Shouldn't happen.
|
let def = (5, maximum (map T.length $ T.lines trendered)) -- fallback: underline whole posting. Shouldn't happen.
|
||||||
in
|
in
|
||||||
@ -628,8 +625,8 @@ checkBalanceAssertionOneCommodityB p@Posting{paccount=assertedacct} assertedamt
|
|||||||
Just idx -> fromMaybe def $ do
|
Just idx -> fromMaybe def $ do
|
||||||
let
|
let
|
||||||
beforeps = take (idx-1) $ tpostings t
|
beforeps = take (idx-1) $ tpostings t
|
||||||
beforepslines = sum $ map (length . T.lines . pcomment) beforeps -- posting comment can generate extra lines (assume only one commodity shown)
|
beforepslines = dbg5 "beforepslines" $ sum $ map (max 1 . length . T.lines . pcomment) beforeps -- posting comment can generate extra lines (assume only one commodity shown)
|
||||||
assertionline <- headMay $ drop (tlines + beforepslines) $ T.lines trendered
|
assertionline <- dbg5 "assertionline" $ headMay $ drop (tlines + beforepslines) $ T.lines trendered
|
||||||
let
|
let
|
||||||
col2 = T.length assertionline
|
col2 = T.length assertionline
|
||||||
l = dropWhile (/= '=') $ reverse $ T.unpack assertionline
|
l = dropWhile (/= '=') $ reverse $ T.unpack assertionline
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user