File tree 1 file changed +13
-5
lines changed
1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -293,10 +293,13 @@ public struct DiagnosticsFormatter {
293
293
)
294
294
)
295
295
296
- // If the line did not end with \n (e.g. the last line), append it manually
297
- if annotatedSource. last != " \n " {
298
- annotatedSource. append ( " \n " )
296
+ // Remove any trailing newline and replace it; this may seem
297
+ // counterintuitive, but if we're running within CMake and we let a
298
+ // '\r\n' through, CMake will turn that into *two* newlines.
299
+ if let last = annotatedSource. last, last. isNewline {
300
+ annotatedSource. removeLast ( )
299
301
}
302
+ annotatedSource. append ( " \n " )
300
303
301
304
let columnsWithDiagnostics = Set (
302
305
annotatedLine. diagnostics. map {
@@ -331,8 +334,13 @@ public struct DiagnosticsFormatter {
331
334
}
332
335
333
336
// Add suffix text.
334
- annotatedSource. append ( annotatedLine. suffixText)
335
- if annotatedSource. last != " \n " {
337
+ if !annotatedLine. suffixText. isEmpty {
338
+ annotatedSource. append ( annotatedLine. suffixText)
339
+
340
+ // See above for an explanation of why we do this
341
+ if let last = annotatedSource. last, last. isNewline {
342
+ annotatedSource. removeLast ( )
343
+ }
336
344
annotatedSource. append ( " \n " )
337
345
}
338
346
}
You can’t perform that action at this time.
0 commit comments