Skip to content

Commit 843af34

Browse files
smoothdeveloperbaronfel
authored andcommitted
Fix the .bsl spurious whitespace (#8219)
* Rename `buff` to `writeViaBuffer` and remove `writeViaBufferWithEnvironmentNewLines` `writeViaBufferWithEnvironmentNewLines` is causing borked output when error message ends with "\n". This is probably dating from far back in the history of the codebase, and it doesn't show in windows console, probably because the console itself has some silly work around line termination... * a bunch of .bsl updated with accurate output * fix one bsl * non change for CI * non change for CI
1 parent 63b073c commit 843af34

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

src/fsharp/fsc.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ let ConsoleErrorLoggerUpToMaxErrors (tcConfigB: TcConfigBuilder, exiter : Exiter
102102
member __.HandleIssue(tcConfigB, err, isError) =
103103
DoWithErrorColor isError (fun () ->
104104
let diag = OutputDiagnostic (tcConfigB.implicitIncludeDir, tcConfigB.showFullPaths, tcConfigB.flatErrors, tcConfigB.errorStyle, isError)
105-
writeViaBufferWithEnvironmentNewLines stderr diag err
105+
writeViaBuffer stderr diag err
106106
stderr.WriteLine())
107107
} :> ErrorLogger
108108

@@ -316,7 +316,7 @@ module InterfaceFileWriter =
316316

317317
for (TImplFile (_, _, mexpr, _, _, _)) in declaredImpls do
318318
let denv = BuildInitialDisplayEnvForSigFileGeneration tcGlobals
319-
writeViaBufferWithEnvironmentNewLines os (fun os s -> Printf.bprintf os "%s\n\n" s)
319+
writeViaBuffer os (fun os s -> Printf.bprintf os "%s\n\n" s)
320320
(NicePrint.layoutInferredSigOfModuleExpr true denv infoReader AccessibleFromSomewhere range0 mexpr |> Layout.squashTo 80 |> Layout.showL)
321321

322322
if tcConfig.printSignatureFile <> "" then os.Dispose()

src/fsharp/fsi/fsi.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,8 @@ type internal FsiStdinSyphon(errorWriter: TextWriter) =
502502
let isError = true
503503
DoWithErrorColor isError (fun () ->
504504
errorWriter.WriteLine();
505-
writeViaBufferWithEnvironmentNewLines errorWriter (OutputDiagnosticContext " " syphon.GetLine) err;
506-
writeViaBufferWithEnvironmentNewLines errorWriter (OutputDiagnostic (tcConfig.implicitIncludeDir,tcConfig.showFullPaths,tcConfig.flatErrors,tcConfig.errorStyle,isError)) err;
505+
writeViaBuffer errorWriter (OutputDiagnosticContext " " syphon.GetLine) err;
506+
writeViaBuffer errorWriter (OutputDiagnostic (tcConfig.implicitIncludeDir,tcConfig.showFullPaths,tcConfig.flatErrors,tcConfig.errorStyle,isError)) err;
507507
errorWriter.WriteLine()
508508
errorWriter.WriteLine()
509509
errorWriter.Flush()))
@@ -548,8 +548,8 @@ type internal ErrorLoggerThatStopsOnFirstError(tcConfigB:TcConfigBuilder, fsiStd
548548
DoWithErrorColor isError (fun () ->
549549
if ReportWarning tcConfigB.errorSeverityOptions err then
550550
fsiConsoleOutput.Error.WriteLine()
551-
writeViaBufferWithEnvironmentNewLines fsiConsoleOutput.Error (OutputDiagnosticContext " " fsiStdinSyphon.GetLine) err
552-
writeViaBufferWithEnvironmentNewLines fsiConsoleOutput.Error (OutputDiagnostic (tcConfigB.implicitIncludeDir,tcConfigB.showFullPaths,tcConfigB.flatErrors,tcConfigB.errorStyle,isError)) err
551+
writeViaBuffer fsiConsoleOutput.Error (OutputDiagnosticContext " " fsiStdinSyphon.GetLine) err
552+
writeViaBuffer fsiConsoleOutput.Error (OutputDiagnostic (tcConfigB.implicitIncludeDir,tcConfigB.showFullPaths,tcConfigB.flatErrors,tcConfigB.errorStyle,isError)) err
553553
fsiConsoleOutput.Error.WriteLine()
554554
fsiConsoleOutput.Error.WriteLine()
555555
fsiConsoleOutput.Error.Flush())

src/fsharp/lib.fs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,19 +313,12 @@ let bufs f =
313313
f buf
314314
buf.ToString()
315315

316-
let buff (os: TextWriter) f x =
316+
// writing to output stream via a string buffer.
317+
let writeViaBuffer (os: TextWriter) f x =
317318
let buf = System.Text.StringBuilder 100
318319
f buf x
319320
os.Write(buf.ToString())
320321

321-
// Converts "\n" into System.Environment.NewLine before writing to os. See lib.fs:buff
322-
let writeViaBufferWithEnvironmentNewLines (os: TextWriter) f x =
323-
let buf = System.Text.StringBuilder 100
324-
f buf x
325-
let text = buf.ToString()
326-
let text = text.Replace("\n", System.Environment.NewLine)
327-
os.Write text
328-
329322
//---------------------------------------------------------------------------
330323
// Imperative Graphs
331324
//---------------------------------------------------------------------------

0 commit comments

Comments
 (0)