mirror of
https://github.com/PowerShell/PowerShell.git
synced 2024-12-11 19:13:49 +08:00
resolve merge conflict (#14969)
This commit is contained in:
parent
44d5ce9e01
commit
2f3f39906f
@ -60,8 +60,38 @@ namespace Microsoft.PowerShell
|
||||
|
||||
_parent = parent;
|
||||
_rawui = new ConsoleHostRawUserInterface(this);
|
||||
SupportsVirtualTerminal = TryTurnOnVtMode();
|
||||
SupportsVirtualTerminal = true;
|
||||
_isInteractiveTestToolListening = false;
|
||||
|
||||
if (ExperimentalFeature.IsEnabled("PSAnsiRendering"))
|
||||
{
|
||||
// check if TERM env var is set
|
||||
// `dumb` means explicitly don't use VT
|
||||
// `xterm-mono` and `xtermm` means support VT, but emit plaintext
|
||||
switch (Environment.GetEnvironmentVariable("TERM"))
|
||||
{
|
||||
case "dumb":
|
||||
SupportsVirtualTerminal = false;
|
||||
break;
|
||||
case "xterm-mono":
|
||||
case "xtermm":
|
||||
PSStyle.Instance.OutputRendering = OutputRendering.PlainText;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// widely supported by CLI tools via https://no-color.org/
|
||||
if (Environment.GetEnvironmentVariable("NO_COLOR") != null)
|
||||
{
|
||||
PSStyle.Instance.OutputRendering = OutputRendering.PlainText;
|
||||
}
|
||||
}
|
||||
|
||||
if (SupportsVirtualTerminal)
|
||||
{
|
||||
SupportsVirtualTerminal = TryTurnOnVtMode();
|
||||
}
|
||||
}
|
||||
|
||||
internal bool TryTurnOnVtMode()
|
||||
|
@ -1008,3 +1008,40 @@ Describe 'Console host name' -Tag CI {
|
||||
(Get-Process -Id $PID).Name | Should -BeExactly 'pwsh'
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'TERM env var' -Tag CI {
|
||||
BeforeAll {
|
||||
$oldTERM = $env:TERM
|
||||
$PSDefaultParameterValues.Add('It:Skip', (-not $EnabledExperimentalFeatures.Contains('PSAnsiRendering')))
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
$env:TERM = $oldTERM
|
||||
$PSDefaultParameterValues.Remove('It:Skip')
|
||||
}
|
||||
|
||||
It 'TERM = "dumb"' {
|
||||
$env:TERM = 'dumb'
|
||||
pwsh -noprofile -command '$Host.UI.SupportsVirtualTerminal' | Should -BeExactly 'False'
|
||||
}
|
||||
|
||||
It 'TERM = "<term>"' -TestCases @(
|
||||
@{ term = "xterm-mono" }
|
||||
@{ term = "xtermm" }
|
||||
) {
|
||||
param ($term)
|
||||
|
||||
$env:TERM = $term
|
||||
pwsh -noprofile -command '$PSStyle.OutputRendering' | Should -BeExactly 'PlainText'
|
||||
}
|
||||
|
||||
It 'NO_COLOR' {
|
||||
try {
|
||||
$env:NO_COLOR = 1
|
||||
pwsh -noprofile -command '$PSStyle.OutputRendering' | Should -BeExactly 'PlainText'
|
||||
}
|
||||
finally {
|
||||
$env:NO_COLOR = $null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user