Skip to content

Commit 65b899c

Browse files
authored
Fix Write-Host to respect OutputRendering = PlainText (#21188)
1 parent 4415386 commit 65b899c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

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)