Permalink
Browse files

ui: support all results of showGenericSourcePos

Resolves #904
  • Loading branch information...
ony authored and simonmichael committed Oct 25, 2018
1 parent 61e3617 commit 99bfebd1a1a42f1672418af631c2bcc928360e78
Showing with 19 additions and 5 deletions.
  1. +2 −0 hledger-lib/Hledger/Data/Transaction.hs
  2. +17 −5 hledger-ui/Hledger/UI/ErrorScreen.hs
@@ -71,6 +71,8 @@ sourceFirstLine = \case
GenericSourcePos _ line _ -> line
JournalSourcePos _ (line, _) -> line
-- | Render source position in human-readable form.
-- Keep in sync with Hledger.UI.ErrorScreen.hledgerparseerrorpositionp (temporary). XXX
showGenericSourcePos :: GenericSourcePos -> String
showGenericSourcePos = \case
GenericSourcePos fp line column -> show fp ++ " (line " ++ show line ++ ", column " ++ show column ++ ")"
@@ -110,15 +110,27 @@ esHandle _ _ = error "event handler called with wrong screen type, should not ha
-- | Parse the file name, line and column number from a hledger parse error message, if possible.
-- Temporary, we should keep the original parse error location. XXX
-- Keep in sync with 'Hledger.Data.Transaction.showGenericSourcePos'
hledgerparseerrorpositionp :: ParsecT Void String t (String, Int, Int)
hledgerparseerrorpositionp = do
anySingle `manyTill` char '"'
f <- anySingle `manyTill` (oneOf ['"','\n'])
string " (line "
l <- read <$> some digitChar
string ", column "
c <- read <$> some digitChar
return (f, l, c)
choice [
do
string " (line "
l <- read <$> some digitChar
string ", column "
c <- read <$> some digitChar
return (f, l, c),
do
string " (lines "
l <- read <$> some digitChar
char '-'
some digitChar
char ')'
return (f, l, 1)
]
-- Unconditionally reload the journal, regenerating the current screen
-- and all previous screens in the history.

0 comments on commit 99bfebd

Please sign in to comment.