Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TerminateStragglers option (Windows) #3764

Merged
10 changes: 10 additions & 0 deletions PSReadLine/Cmdlets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ public object ListPredictionTooltipColor
set => _listPredictionTooltipColor = VTColorUtils.AsEscapeSequence(value);
}

public bool TerminateStragglers { get; set; }

internal string _defaultTokenColor;
internal string _commentColor;
internal string _keywordColor;
Expand Down Expand Up @@ -808,6 +810,14 @@ public PredictionViewStyle PredictionViewStyle
[Parameter]
public Hashtable Colors { get; set; }

[Parameter]
public SwitchParameter TerminateStragglers
{
get => _terminateStragglers.GetValueOrDefault();
set => _terminateStragglers = value;
}
internal SwitchParameter? _terminateStragglers;

[ExcludeFromCodeCoverage]
protected override void EndProcessing()
{
Expand Down
9 changes: 9 additions & 0 deletions PSReadLine/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Management.Automation;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.PowerShell.PSReadLine;

Expand Down Expand Up @@ -167,6 +168,14 @@ private void SetOptionsInternal(SetPSReadLineOption options)
}
}
}
if (options._terminateStragglers.HasValue)
{
Options.TerminateStragglers = options.TerminateStragglers;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
PlatformWindows.SetTerminateStragglers(Options.TerminateStragglers);
}
jazzdelightsme marked this conversation as resolved.
Show resolved Hide resolved
}
}

private void SetKeyHandlerInternal(string[] keys, Action<ConsoleKeyInfo?, object> handler, string briefDescription, string longDescription, ScriptBlock scriptBlock)
Expand Down
3 changes: 3 additions & 0 deletions PSReadLine/PSReadLine.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ $d = [Microsoft.PowerShell.KeyHandler]::GetGroupingDescription($_.Group)
<ListItem>
<PropertyName>PredictionViewStyle</PropertyName>
</ListItem>
<ListItem>
<PropertyName>TerminateStragglers</PropertyName>
</ListItem>
<ListItem>
<Label>CommandColor</Label>
<ScriptBlock>[Microsoft.PowerShell.VTColorUtils]::FormatColor($_.CommandColor)</ScriptBlock>
Expand Down