diff --git a/hledger-lib/Hledger/Read/JournalReader.hs b/hledger-lib/Hledger/Read/JournalReader.hs index 311020246..238f751fc 100644 --- a/hledger-lib/Hledger/Read/JournalReader.hs +++ b/hledger-lib/Hledger/Read/JournalReader.hs @@ -191,11 +191,6 @@ includedirectivep = do lift (skipSome spacenonewline) filename <- T.unpack <$> takeWhileP Nothing (/= '\n') -- don't consume newline yet - -- save parent state - parentParserState <- getParserState - parentj <- get - - let childj = newJournalWithParseStateFrom parentj parentpos <- getPosition -- read child input @@ -203,6 +198,12 @@ includedirectivep = do filepath <- lift $ expandPath curdir filename `orRethrowIOError` (show parentpos ++ " locating " ++ filename) childInput <- lift $ readFilePortably filepath `orRethrowIOError` (show parentpos ++ " reading " ++ filepath) + -- save parent state + parentParserState <- getParserState + parentj <- get + + let childj = newJournalWithParseStateFrom parentj + -- set child state setInput childInput pushPosition $ initialPos filepath