@@ -2045,6 +2045,7 @@ type FormattedDiagnosticDetailedInfo =
2045
2045
Canonical: FormattedDiagnosticCanonicalInformation
2046
2046
Message: string
2047
2047
Context: string option
2048
+ DiagnosticStyle: DiagnosticStyle
2048
2049
}
2049
2050
2050
2051
[<RequireQualifiedAccess>]
@@ -2118,7 +2119,7 @@ let FormatDiagnosticLocation (tcConfig: TcConfig) (m: Range) : FormattedDiagnost
2118
2119
| DiagnosticStyle.Rich ->
2119
2120
let file = file.Replace( '/' , Path.DirectorySeparatorChar)
2120
2121
let m = withStart ( mkPos m.StartLine ( m.StartColumn + 1 )) m
2121
- ( sprintf " ◦→ %s (%d ,%d )" file m.StartLine m.StartColumn), m, file
2122
+ ( sprintf " \n --> %s (%d ,%d )" file m.StartLine m.StartColumn), m, file
2122
2123
2123
2124
{
2124
2125
Range = m
@@ -2164,7 +2165,7 @@ let CollectFormattedDiagnostics (tcConfig: TcConfig, severity: FSharpDiagnosticS
2164
2165
| DiagnosticStyle.Default
2165
2166
| DiagnosticStyle.Test -> sprintf " %s FS%04d : " message errorNumber
2166
2167
| DiagnosticStyle.VisualStudio -> sprintf " %s %s FS%04d : " subcategory message errorNumber
2167
- | DiagnosticStyle.Rich -> sprintf " \n ◦→ %s FS%04d : " message errorNumber
2168
+ | DiagnosticStyle.Rich -> sprintf " %s FS%04d : " message errorNumber
2168
2169
2169
2170
let canonical : FormattedDiagnosticCanonicalInformation =
2170
2171
{
@@ -2179,11 +2180,8 @@ let CollectFormattedDiagnostics (tcConfig: TcConfig, severity: FSharpDiagnosticS
2179
2180
| DiagnosticStyle.Gcc
2180
2181
| DiagnosticStyle.Default
2181
2182
| DiagnosticStyle.Test
2183
+ | DiagnosticStyle.Rich
2182
2184
| DiagnosticStyle.VisualStudio -> diagnostic.FormatCore( tcConfig.flatErrors, suggestNames)
2183
- | DiagnosticStyle.Rich ->
2184
- diagnostic.FormatCore( tcConfig.flatErrors, suggestNames) .Split([| '\n' |])
2185
- |> Array.map ( fun msg -> " \n ◦ " + msg)
2186
- |> String.Concat
2187
2185
2188
2186
let context =
2189
2187
match tcConfig.diagnosticStyle with
@@ -2201,14 +2199,14 @@ let CollectFormattedDiagnostics (tcConfig: TcConfig, severity: FSharpDiagnosticS
2201
2199
|> System.IO.File.ReadAllLines
2202
2200
2203
2201
if m.StartLine = m.EndLine then
2204
- $" \n ◦ {m.StartLine} |{content[m.StartLine - 1]}\n "
2205
- + $""" ◦ {String.init (m.StartColumn + 3) (fun _ -> " ")}^ {String.init (m.EndColumn - m.StartColumn) (fun _ -> "~") }"""
2202
+ $" \n {m.StartLine} | {content[m.StartLine - 1]}\n "
2203
+ + $""" {String.make (m.StartColumn + 6) ' '} {String.make (m.EndColumn - m.StartColumn) '^' }"""
2206
2204
|> Some
2207
2205
else
2208
2206
content
2209
2207
|> fun lines -> Array.sub lines ( m.StartLine - 1 ) ( m.EndLine - m.StartLine - 1 )
2210
2208
|> Array.fold
2211
- ( fun ( context , lineNumber ) line -> ( context + $" \n ◦ {lineNumber} |{line}" , lineNumber + 1 ))
2209
+ ( fun ( context , lineNumber ) line -> ( context + $" \n {lineNumber} | {line}" , lineNumber + 1 ))
2212
2210
( " " , ( m.StartLine))
2213
2211
|> fst
2214
2212
|> Some
@@ -2220,6 +2218,7 @@ let CollectFormattedDiagnostics (tcConfig: TcConfig, severity: FSharpDiagnosticS
2220
2218
Context = context
2221
2219
Canonical = canonical
2222
2220
Message = message
2221
+ DiagnosticStyle = tcConfig.diagnosticStyle
2223
2222
}
2224
2223
2225
2224
errors.Add( FormattedDiagnostic.Long( severity, entry))
@@ -2247,16 +2246,33 @@ type PhasedDiagnostic with
2247
2246
match e with
2248
2247
| FormattedDiagnostic.Short(_, txt) -> buf.AppendString txt
2249
2248
| FormattedDiagnostic.Long(_, details) ->
2250
- match details.Location with
2251
- | Some l when not l.IsEmpty ->
2252
- buf.AppendString l.TextRepresentation
2253
- // Because details.Context depends on the value of details.Location, if details.Location is not None, details.Context can be accessed directly.
2254
- if details.Context.IsSome then
2255
- buf.AppendString details.Context.Value
2256
- | _ -> ()
2249
+ match details.DiagnosticStyle with
2250
+ | DiagnosticStyle.Emacs
2251
+ | DiagnosticStyle.Gcc
2252
+ | DiagnosticStyle.Test
2253
+ | DiagnosticStyle.VisualStudio
2254
+ | DiagnosticStyle.Default ->
2255
+ match details.Location with
2256
+ | Some l when not l.IsEmpty ->
2257
+ buf.AppendString l.TextRepresentation
2258
+
2259
+ if details.Context.IsSome then
2260
+ buf.AppendString details.Context.Value
2261
+ | _ -> ()
2262
+
2263
+ buf.AppendString details.Canonical.TextRepresentation
2264
+ buf.AppendString details.Message
2265
+ | DiagnosticStyle.Rich ->
2266
+ buf.AppendString details.Canonical.TextRepresentation
2267
+ buf.AppendString details.Message
2268
+
2269
+ match details.Location with
2270
+ | Some l when not l.IsEmpty ->
2271
+ buf.AppendString l.TextRepresentation
2257
2272
2258
- buf.AppendString details.Canonical.TextRepresentation
2259
- buf.AppendString details.Message
2273
+ if details.Context.IsSome then
2274
+ buf.AppendString details.Context.Value
2275
+ | _ -> ()
2260
2276
2261
2277
member diagnostic.OutputContext ( buf , prefix , fileLineFunction ) =
2262
2278
match diagnostic.Range with
0 commit comments