From 2015c678413b78b57d5bf61e5a52eff7ce3c74e1 Mon Sep 17 00:00:00 2001 From: Matthias Voigt Date: Fri, 10 Nov 2023 15:33:15 +0100 Subject: [PATCH 1/2] 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)); } } From f30bbc56f50d66fcf0fe132ff75ed47990d3106a Mon Sep 17 00:00:00 2001 From: Matthias Voigt Date: Mon, 13 Nov 2023 11:12:51 +0100 Subject: [PATCH 2/2] Fixed param documentation for OutputWindowPane.WriteAsync(string value) --- .../Helpers/OutputWindowPane.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/toolkit/Community.VisualStudio.Toolkit.Shared/Helpers/OutputWindowPane.cs b/src/toolkit/Community.VisualStudio.Toolkit.Shared/Helpers/OutputWindowPane.cs index b9505f7..498518b 100644 --- a/src/toolkit/Community.VisualStudio.Toolkit.Shared/Helpers/OutputWindowPane.cs +++ b/src/toolkit/Community.VisualStudio.Toolkit.Shared/Helpers/OutputWindowPane.cs @@ -268,7 +268,7 @@ public async Task WriteLineAsync(string value) /// /// 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. + /// The text value to write. public async Task WriteAsync(string value) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();