1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 01:42:43 +03:00

showError doesn’t append a newline.

This commit is contained in:
Rob Rix 2017-06-06 09:45:44 -04:00
parent 9a650fbb51
commit e1476bf067
2 changed files with 2 additions and 2 deletions

View File

@ -174,7 +174,7 @@ showError source error@Error{..}
= withSGRCode [SetConsoleIntensity BoldIntensity] (showSourcePos Nothing errorPos) . showString ": " . withSGRCode [SetColor Foreground Vivid Red] (showString "error") . showString ": " . showExpectation error . showChar '\n'
. showString context -- actualLines results include line endings, so no newline here
. showString (replicate (succ (Info.column errorPos + lineNumberDigits)) ' ') . withSGRCode [SetColor Foreground Vivid Green] (showChar '^') . showChar '\n'
. showString (prettyCallStack callStack) . showChar '\n'
. showString (prettyCallStack callStack)
$ ""
where context = maybe "\n" (toS . Source.sourceText . sconcat) (nonEmpty [ Source.Source (toS (showLineNumber i)) <> Source.Source ": " <> l | (i, l) <- zip [1..] (Source.actualLines source), inRange (Info.line errorPos - 2, Info.line errorPos) i ])
showLineNumber n = let s = show n in replicate (lineNumberDigits - length s) ' ' <> s

View File

@ -66,7 +66,7 @@ runParser parser = case parser of
let Result err term = assign assignment source ast
case term of
Just term -> do
traverse_ (putStr . showError source) (toList err <> termErrors term)
traverse_ (putStrLn . showError source) (toList err <> termErrors term)
pure term
Nothing -> pure (errorTerm source err)
TreeSitterParser language tslanguage -> treeSitterParser language tslanguage