Skip to content

Commit

Permalink
redirect Console.Out to stderr
Browse files Browse the repository at this point in the history
Redirecting Console.Out to use the standard error stream to try reduce
the chances of stdout being corrupted by non-rpc content.
  • Loading branch information
HarleyRossetto committed Dec 17, 2024
1 parent 171270f commit bd9ab58
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ static async Task RunAsync(ServerConfiguration serverConfiguration, Cancellation
if (serverConfiguration.UseStdIo)
{
server = new LanguageServerHost(Console.OpenStandardInput(), Console.OpenStandardOutput(), exportProvider, languageServerLogger, typeRefResolver);
// Redirect Console.Out to try prevent the standard output stream from being corrupted.
Console.SetOut(new StreamWriter(Console.OpenStandardError()));
}
else
{
Expand Down

0 comments on commit bd9ab58

Please sign in to comment.