From 2015c678413b78b57d5bf61e5a52eff7ce3c74e1 Mon Sep 17 00:00:00 2001 From: Matthias Voigt Date: Fri, 10 Nov 2023 15:33:15 +0100 Subject: [PATCH] Added Write without new line to OutputWindowPane Added methods void Write(string value); async Task WriteAsync(string value); Moved logic from WriteLineAsync to WriteAsync --- .../Helpers/OutputWindowPane.cs | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/toolkit/Community.VisualStudio.Toolkit.Shared/Helpers/OutputWindowPane.cs b/src/toolkit/Community.VisualStudio.Toolkit.Shared/Helpers/OutputWindowPane.cs index 4a24c2f..b9505f7 100644 --- a/src/toolkit/Community.VisualStudio.Toolkit.Shared/Helpers/OutputWindowPane.cs +++ b/src/toolkit/Community.VisualStudio.Toolkit.Shared/Helpers/OutputWindowPane.cs @@ -236,6 +236,18 @@ public void WriteLine(string value) }); } + /// + /// Writes the given text to the Output window pane. + /// + /// The text value to write. + public void Write(string value) + { + ThreadHelper.JoinableTaskFactory.Run(async () => + { + await WriteAsync(value); + }); + } + /// /// Writes a new line to the Output window pane. /// @@ -249,6 +261,15 @@ public Task WriteLineAsync() /// /// The text value to write. May be an empty string, in which case a newline is written. public async Task WriteLineAsync(string value) + { + await WriteAsync(value + Environment.NewLine); + } + + /// + /// Writes the given text to the Output window pane. + /// + /// The text value to write. May be an empty string, in which case a newline is written. + public async Task WriteAsync(string value) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); @@ -261,11 +282,11 @@ public async Task WriteLineAsync(string value) if (_pane is IVsOutputWindowPaneNoPump nopump) { - nopump.OutputStringNoPump(value + Environment.NewLine); + nopump.OutputStringNoPump(value); } else { - ErrorHandler.ThrowOnFailure(_pane.OutputStringThreadSafe(value + Environment.NewLine)); + ErrorHandler.ThrowOnFailure(_pane.OutputStringThreadSafe(value)); } }