Skip to content

Commit

Permalink
Added Write without new line to OutputWindowPane
Browse files Browse the repository at this point in the history
Added methods
void Write(string value);
async Task WriteAsync(string value);

Moved logic from WriteLineAsync to WriteAsync
  • Loading branch information
Matt-17 committed Nov 10, 2023
1 parent cb2f77d commit 2015c67
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,18 @@ public void WriteLine(string value)
});
}

/// <summary>
/// Writes the given text to the Output window pane.
/// </summary>
/// <param name="value">The text value to write.</param>
public void Write(string value)
{
ThreadHelper.JoinableTaskFactory.Run(async () =>
{
await WriteAsync(value);
});
}

/// <summary>
/// Writes a new line to the Output window pane.
/// </summary>
Expand All @@ -249,6 +261,15 @@ public Task WriteLineAsync()
/// </summary>
/// <param name="value">The text value to write. May be an empty string, in which case a newline is written.</param>
public async Task WriteLineAsync(string value)
{
await WriteAsync(value + Environment.NewLine);
}

/// <summary>
/// Writes the given text to the Output window pane.
/// </summary>
/// <param name="value">The text value to write. May be an empty string, in which case a newline is written.</param>
public async Task WriteAsync(string value)
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

Expand All @@ -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));
}
}

Expand Down

0 comments on commit 2015c67

Please sign in to comment.