Skip to content

Commit f58edfb

Browse files
authored
Fix pretty printer for diagnostic ranges (#871)
With the current implementation, VS Code will show "1:1" for the top left corner, but the pretty printer renders this poisition to "1:0". This is particularly interesting for people building command line tools using `ghcide`, like the our DAML compiler at Digital Asset. tools with command line drivers, like us at Digital Asset. I would argue that VS Code has the ultimate authority on this since we can't change what it displays without also moving the squiggly lines. This PR fixes the discrepance by simply adding one to the column number in the prtty printer, like we do for the line number.
1 parent 6af874d commit f58edfb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Development/IDE/Types/Diagnostics.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ type FileDiagnostic = (NormalizedFilePath, ShowDiagnostic, Diagnostic)
8989

9090
prettyRange :: Range -> Doc Terminal.AnsiStyle
9191
prettyRange Range{..} = f _start <> "-" <> f _end
92-
where f Position{..} = pretty (_line+1) <> colon <> pretty _character
92+
where f Position{..} = pretty (_line+1) <> colon <> pretty (_character+1)
9393

9494
stringParagraphs :: T.Text -> Doc a
9595
stringParagraphs = vcat . map (fillSep . map pretty . T.words) . T.lines

0 commit comments

Comments
 (0)