ui: support all results of showGenericSourcePos
Resolves simonmichael/hledger#904
This commit is contained in:
parent
61e36173b4
commit
99bfebd1a1
@ -71,6 +71,8 @@ sourceFirstLine = \case
|
|||||||
GenericSourcePos _ line _ -> line
|
GenericSourcePos _ line _ -> line
|
||||||
JournalSourcePos _ (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 :: GenericSourcePos -> String
|
||||||
showGenericSourcePos = \case
|
showGenericSourcePos = \case
|
||||||
GenericSourcePos fp line column -> show fp ++ " (line " ++ show line ++ ", column " ++ show column ++ ")"
|
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.
|
-- | 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
|
-- 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 :: ParsecT Void String t (String, Int, Int)
|
||||||
hledgerparseerrorpositionp = do
|
hledgerparseerrorpositionp = do
|
||||||
anySingle `manyTill` char '"'
|
anySingle `manyTill` char '"'
|
||||||
f <- anySingle `manyTill` (oneOf ['"','\n'])
|
f <- anySingle `manyTill` (oneOf ['"','\n'])
|
||||||
|
choice [
|
||||||
|
do
|
||||||
string " (line "
|
string " (line "
|
||||||
l <- read <$> some digitChar
|
l <- read <$> some digitChar
|
||||||
string ", column "
|
string ", column "
|
||||||
c <- read <$> some digitChar
|
c <- read <$> some digitChar
|
||||||
return (f, l, c)
|
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
|
-- Unconditionally reload the journal, regenerating the current screen
|
||||||
-- and all previous screens in the history.
|
-- and all previous screens in the history.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user