Skip to content

Commit aecc797

Browse files
SteveL-MSFTAmro Khalil
authored andcommitted
Fix Write-Host to respect OutputRendering = PlainText (PowerShell#21188)
1 parent d3fc1f1 commit aecc797

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,14 @@ public override
209209
return;
210210
}
211211

212-
_externalUI.Write(foregroundColor, backgroundColor, value);
212+
if (PSStyle.Instance.OutputRendering == OutputRendering.PlainText)
213+
{
214+
_externalUI.Write(value);
215+
}
216+
else
217+
{
218+
_externalUI.Write(foregroundColor, backgroundColor, value);
219+
}
213220
}
214221

215222
/// <summary>
@@ -303,7 +310,14 @@ public override
303310
return;
304311
}
305312

306-
_externalUI.WriteLine(foregroundColor, backgroundColor, value);
313+
if (PSStyle.Instance.OutputRendering == OutputRendering.PlainText)
314+
{
315+
_externalUI.WriteLine(value);
316+
}
317+
else
318+
{
319+
_externalUI.WriteLine(foregroundColor, backgroundColor, value);
320+
}
307321
}
308322

309323
/// <summary>

0 commit comments

Comments
 (0)